AMP Analytics "destinationDomains" 在链接器配置中不工作
AMP Analytics "destinationDomains" not working in Linker config
我正在尝试为从我的 AMP 网站到我的域的链接启用链接器字符串。
当前配置仅适用于 "canonical" 域的链接,这是默认行为。
我也在尝试为发送到我的应用域的链接启用它。
我尝试了以下代码的多种变体(包括使用无效的 JSON 数组字符串,如此处文档所述:https://ampbyexample.com/advanced/joining_analytics_sessions/#destination-domains)但这似乎不起作用.
我希望这是语法或配置问题,但我开始怀疑了。这是我的代码:
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars": {
"gtag_id": "AW-XXXXXX",
"config": {
"UA-XXXXX-X": {
"groups": "default"
},
"AW-XXXXXX": {
"groups": "default"
}
}
},
"linkers": {
"enabled": true,
"proxyOnly": false,
"destinationDomains": [ "amp.mydomain.com", "www.mydomain.com", "app.altdomain.ly" ]
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
我也试过用嵌套的 <paramName>
对象设置它,如下所示,但我得到了相同的结果(仅适用于规范):
...
"linkers": {
"Linker1": {
"ids": {
"_cid": "CLIENT_ID"
},
"proxyOnly": false,
"destinationDomains": [ "amp.mydomain.com", "www.mydomain.com", "app.altdomain.ly" ],
"enabled": true
}
}
...
您可以先检查 linkers
在 AMP 中的正确格式:
"linkers": {
<paramName>: {
ids: <Object>,
proxyOnly: <boolean>,
destinationDomains: <Array<string>>,
enabled: <boolean>
}
}
paramName
- This user defined name determines the name of the query
parameter appended to the links.
ids
- An object containing key-value pairs that is partially encoded
and passed along in the param.
proxyOnly
- (optional) Flag indicating whether the links should only
be appended on pages served on a proxy origin. Defaults to true.
destinationDomains
- (optional) Links will be decorated if their
domains are included in this array. Defaults to canonical and source
domains.
enabled
- Publishers must explicity set this to true to opt-in to
using this feature.
此链接器使用此配置生成此结构中的字符串:<paramName>=<version>*<checkSum>*<idName1>*<idValue1>*<idName2>*<idValue2>...
有关详细信息,请参阅 Linker Param Format。
由于您使用的是 gtag,我认为您可能需要使用 GTAG 的配置来配置域。说明可用 here.
基本上,配置如下所示:
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars" : {
"gtag_id": "<GA_TRACKING_ID>",
"config" : {
"<GA_TRACKING_ID>": {
"groups": "default",
"linker": { "domains": ["example.com", "example2.com"] }
}
}
}
}
</script>
</amp-analytics>
我正在尝试为从我的 AMP 网站到我的域的链接启用链接器字符串。
当前配置仅适用于 "canonical" 域的链接,这是默认行为。
我也在尝试为发送到我的应用域的链接启用它。
我尝试了以下代码的多种变体(包括使用无效的 JSON 数组字符串,如此处文档所述:https://ampbyexample.com/advanced/joining_analytics_sessions/#destination-domains)但这似乎不起作用.
我希望这是语法或配置问题,但我开始怀疑了。这是我的代码:
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars": {
"gtag_id": "AW-XXXXXX",
"config": {
"UA-XXXXX-X": {
"groups": "default"
},
"AW-XXXXXX": {
"groups": "default"
}
}
},
"linkers": {
"enabled": true,
"proxyOnly": false,
"destinationDomains": [ "amp.mydomain.com", "www.mydomain.com", "app.altdomain.ly" ]
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
我也试过用嵌套的 <paramName>
对象设置它,如下所示,但我得到了相同的结果(仅适用于规范):
...
"linkers": {
"Linker1": {
"ids": {
"_cid": "CLIENT_ID"
},
"proxyOnly": false,
"destinationDomains": [ "amp.mydomain.com", "www.mydomain.com", "app.altdomain.ly" ],
"enabled": true
}
}
...
您可以先检查 linkers
在 AMP 中的正确格式:
"linkers": {
<paramName>: {
ids: <Object>,
proxyOnly: <boolean>,
destinationDomains: <Array<string>>,
enabled: <boolean>
}
}
paramName
- This user defined name determines the name of the query parameter appended to the links.
ids
- An object containing key-value pairs that is partially encoded and passed along in the param.
proxyOnly
- (optional) Flag indicating whether the links should only be appended on pages served on a proxy origin. Defaults to true.
destinationDomains
- (optional) Links will be decorated if their domains are included in this array. Defaults to canonical and source domains.
enabled
- Publishers must explicity set this to true to opt-in to using this feature.
此链接器使用此配置生成此结构中的字符串:<paramName>=<version>*<checkSum>*<idName1>*<idValue1>*<idName2>*<idValue2>...
有关详细信息,请参阅 Linker Param Format。
由于您使用的是 gtag,我认为您可能需要使用 GTAG 的配置来配置域。说明可用 here.
基本上,配置如下所示:
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars" : {
"gtag_id": "<GA_TRACKING_ID>",
"config" : {
"<GA_TRACKING_ID>": {
"groups": "default",
"linker": { "domains": ["example.com", "example2.com"] }
}
}
}
}
</script>
</amp-analytics>