2017-08-02 85 views
0

我試圖在GTM中將「content id」的值作爲AMP變量傳遞。但是,我無法得到它拿起值大概]由於在關鍵的空白:通過GTM AMP變量傳遞帶空格的鍵

<amp-analytics config="http://example.com/config.json"> 
<script type="application/json"> 
{ 
    "requests": { 
    "pageview": "https://example.com/... 
    }, 
    "vars": { 
    "content id": "ABC123", 
    "author": "John Smith" 
    ... 

其它鍵(例如作者)成功返回值。我試過後%20id等組合,甚至直接將該值作爲CD(繞過GTM變量)。有沒有人對AMP/GTM使用空格處理AMP文章變數有所瞭解?

+0

你需要顯示的頁面;其他事情可能會在這裏引起問題。短期內,請嘗試content_id。 –

+0

您可能想要查看啓用[變量替換](https://github.com/ampproject/amphtml/blob/master/extensions/amp-form/amp-form.md#variable-substitutions)中列出的AMP功能這[GitHub文章](https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md)。此外,此[博文](https://analytics.googleblog.com/2016/10/google-tag-manager-giving-mobile.html)可能會有所幫助。 – Teyam

回答

1

不能在變量名稱中使用的空間,您可以使用URL編碼版本是這樣的:

<script type="application/json"> 
{ 
    "vars": { 
    "content%20id": "ABC123", 
    "author": "John Smith" 
    } 
} 
</script> 

然後在GTM使用相同的content%20id變量。

但當然最好的方法就是使用像content_id