dimasfrolov
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [AMP] GA4 on AMP (Google Analytics 4)I figure out how to do this.
Here is my code:<amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-WHLX4Z8>m.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- This reply was modified 4 years ago by dimasfrolov.
Viewing 1 replies (of 1 total)