有没有办法添加不同的Google Analytics跟踪帐户?我一直在寻找,但我只找到示例,网站正在使用1个帐户:
<script type="application/json">
{
"requests": {
"pageview": "https://example.com/analytics?url=${canonicalUrl}&title=${title}&acct=${account}",
"event": "https://example.com/analytics?eid=${eventId}&elab=${eventLabel}&acct=${account}"
},
"vars": {
"account": "ABC123"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
},...
答案 0 :(得分:3)
您可以复制粘贴amp-analytics标签两次。或者您可以使用两个触发器。以下是一些例子:
两个单独的标签:
<amp-analytics>
<script type="application/json">
{
"vars": {
"account": "ABC123"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
},...
<amp-analytics>
<script type="application/json">
{
"vars": {
"account": "PQR987"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
},...
两个触发器:
<amp-analytics>
<script type="application/json">
{
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
"vars": {
"account": "ABC123"
},
},
"trackPageview2": {
"on": "visible",
"request": "pageview"
"vars": {
"account": "PQR987"
},
},...
答案 1 :(得分:2)
我们在“请求”之后错过了一个逗号:“pageview”
<amp-analytics type="googleanalytics" id="analytics-ga">
<script type="application/json">
{
"triggers": {
"trackPageviewAmp": {
"on": "visible",
"request": "pageview",
"vars": {
"account": "UA-000000-2"
}
}
},
"triggers": {
"trackPageviewMain": {
"on": "visible",
"request": "pageview",
"vars": {
"account": "UA-000000-1"
}
}
}
}
</script>
</amp-analytics>
答案 2 :(得分:-1)
在AMPforWP(Wordpress),Google Analytics(分析),高级Google Analytics(分析)插件中,要求使用“ JSON”格式。通过以这种格式插入仅触发器工作,triggers2将不会。