Support » Plugin: AMP » GA4 on AMP (Google Analytics 4)

  • Resolved tripledm

    (@tripledm)


    Will GA4 work on AMP with gtag?

    So add another type = gtag and then:

    {
    “vars”: {
    “gtag_id”: “G-[your id]”,
    “config”: {
    “G-[your id]”: { “groups”: “default” }
    }
    },
    “extraUrlParams”: {
    “cd1”: “{author_name}”,
    “cd2”: “{category}”,
    “cd3”: “{published_at}”,
    “cd5”: “{tags}”,
    “cd6”: “amperage”
    },
    “triggers”: {
    “trackPageview”: {
    “on”: “visible”,
    “request”: “pageview”
    }
    }
    }

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Milind More

    (@milindmore22)

    Thanks for reaching out, great question. While we are investigating this further, you can use this support documentation to include both the GA4 property type (G-) along with universal (UA-) property in the same code snippet to ensure your Analytics is firing. It’s possible to associate both tags within Google Analytics

    We will report back to you once we have more information

    Thread Starter tripledm

    (@tripledm)

    HI Milind, thank you for the response.

    Just to double check do I use/ set multiple accounts like this;

    “vars”: {
    “gtag_id”: “UA-[your id]”,
    “config”: {
    “UA-[your id]”: { “groups”: “default” },
    “G-[your id]”: { “groups”: “default” }
    }

    Is this the correct way so the G- number for GA4 only in config?

    Thread Starter tripledm

    (@tripledm)

    they do run together so I get the stats on GA3 but not on GA4 but at least it’s setup IF this is the correct way to set it up but let me know if not. Thank you.

    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

    • This reply was modified 1 year, 10 months ago by dimasfrolov.
    Thread Starter tripledm

    (@tripledm)

    thank you dimasfrolov, where does the client ID come from? I don’t need timers but I can see how the triggers are set for requesting an event so can maybe put something together with that.

    GA4 isn’t fully supported in AMP as of yet, but you can subscribe to the following GitHub issue for further information:
    https://github.com/ampproject/amphtml/issues/30903

    Thread Starter tripledm

    (@tripledm)

    Thank you James. Yes I noticed after many attempts no errors but no data lol. Really hope they complete support for it on AMP soon 😉

    Anyone get GA4 working on their AMP pages yet?

    @honeytrek Unfortunately GA4 isn’t compatible with AMP just yet. Feel free to subscribe to the below GitHub issue for further information:
    https://github.com/ampproject/amphtml/issues/24621

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘GA4 on AMP (Google Analytics 4)’ is closed to new replies.