• Resolved Danishsard

    (@danishsard)


    Google analytics 4 – tag

    Hello, when I choose an analyst in the AMP plugin and google there. Should I enter the analytical number 4 in these fields XXX-XXX-X, does it not work with this 4?

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

    (@milindmore22)

    Hello @danishsard

    Thank you for contacting us! There is an upstream Github issue opened regarding GA4 support in AMP; there you can find the latest updates regarding the implementation of GA4 on the GitHub issue. Once upstream (product) support for AMP in GA4 is added, the AMP plugin for WordPress will make it available.

    Currently, there is no official solution provided by AMP and Analytics team, however, you can mark the GA4 Analytics script as px verified so that it won’t be removed by the AMP validator

    We are also working on a solution to mark GA4 scripts automatically px verified, you can follow that progress by watching this GitHub issue

    You can also mark scripts data-px-verified manually, make sure that you are on the Standard template mode then add the data-px-verified-tag attribute in your script tag that isn’t valid AMP.

    ⚠️ The user should make sure that the non-AMP markup doesn’t negatively impact Page Experience.

    ⚠️ The above will not work well in Transitional or Reader Mode as those already have non-AMP versions linked and might create validation errors on Google Search Console.

    So how can I add GA4 to my site then?

    Example: adding GA4 with data-px-verified attribute.

    add_action( 'wp_head', function () {
    	?>
    	<script async src="https://www.googletagmanager.com/gtag/js?id=ABC123" data-px-verified-tag></script>
    	<script data-px-verified-tag>
    		window.dataLayer = window.dataLayer || [];
    		function gtag(){
    			dataLayer.push(arguments);
    		}
    		gtag('js', new Date());
    		gtag('config', 'ABC123');
    		gtag('config', 'G-XXXXXXXX');
    	</script>
    	<?php
    });

    PS: You can also try the plugin AMP Google Analytics 4 Support which is based on a trick solution it is not officially supported but a working solution. if you are looking for basic things.

    Hope this is helpful!

    Thread Starter Danishsard

    (@danishsard)

    I just notice that the products from google are incompatible with each other and cause problems – AMP, this site kit, constantly problems everywhere.

    You need to install 2 plugins to make 1 thing work.

    So currently AMP will not work with Google Analytics 4.

    Thank you for your story – personally, I don’t understand anything of it, I don’t know anything about it. It’s all too confused already. This will disable AMP from the site for now.

    Is there a chance that the AMP plugin will support Google Analytics 4 in some understandable way?

    Plugin Support Milind More

    (@milindmore22)

    Hello @danishsard

    Sorry for the experience of AMP

    Is there a chance that the AMP plugin will support Google Analytics 4 in some understandable way?

    AMP plugin will mark all GA4 scripts PX Verify (it will add data-px-verified-tag attribute for <script> tag) automatically as explained in this GitHub issue, no action is needed from your end, the change will be adopted in the future plugin release.

    Plugin Support Milind More

    (@milindmore22)

    @danishsard As we didn’t receive a response I’ll mark this as resolved. Feel free to open a new support topic if you require any further assistance.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Google analytics 4 – tag’ is closed to new replies.