Multiple Google Tracking Codes on AMP pages

拟墨画扇 提交于 2019-12-07 15:36:36

You can copy paste the amp-analytics tag twice. Or you can use use two triggers. Here are some examples:

Two separate tags:

<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"
        },...

Two triggers:

<amp-analytics>
<script type="application/json">
    {
    "triggers": {
        "trackPageview": {
            "on": "visible",
            "request": "pageview"
            "vars": {
              "account": "ABC123"
            },
        },
        "trackPageview2": {
            "on": "visible",
            "request": "pageview"
            "vars": {
              "account": "PQR987"
            },
        },...

We're just missing a comma after "request": "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>

In the AMPforWP (Wordpress), Google Analytics, Advanced Google Analytics plugin, the "JSON" format is requested. By inserting in this format only triggers work, triggers2 will not.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!