Forum Replies Created

Viewing 1 replies (of 1 total)
  • dimasfrolov

    (@dimasfrolov)

    I figure out how to do this.
    Here is my code:

    <amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-WHLX4Z8&gtm.url=SOURCE_URL" data-credentials="include">
        <script type="application/json">
        {
            "vars": {
                "ga4Id": "G-7F3BP1QRP4",
                "clientId": "358305820.1572693476"
            },
            "requests" : {
                "event_g4": "https://www.google-analytics.com/collect?v=2&_v=a1&ds=AMP&aip&_s=2&cid=${clientId}&ul=en&de=UTF-8&aip&dt=${sourceUrl}&tid=${ga4Id}&dl=${sourceUrl}&t=event&en=${eventName}&ea=${eventAction}&ec=${eventCategory}&el=${eventLabel}"
            },
            "triggers": {
                "trackPageview": {
                    "on": "visible",
                    "request": "event_g4"
                },
                "ga4pageTimer15": {
                    "on": "timer",
                    "request": "event_g4",
                    "timerSpec": {
                        "interval": 15,
                        "maxTimerLength": 600
                    },
                    "vars": {
                        "eventCategory": "Timing",
                        "eventAction": "15sec timer",
                        "eventName": "pageTimer15",
                        "eventLabel": "Time over 15 sec"
                    }
                }
           }
       }
      </script>
    </amp-analytics>
    

    I mixed the standard GA code with a new GA4 id.
    Hope it will help you.
    You can see how it works on my website: dimasfrolov.com

Viewing 1 replies (of 1 total)