Support » Plugin: Woody code snippets - Insert Header Footer Code, AdSense Ads » Google Analytics script running 3 times on each page

  • I have added the following GA script as a snippet:

    <script async src=<?PHP print ('"https://www.googletagmanager.com/gtag/js?id='.$gaid.'"'); ?>></script>
    <script>
    var gaid = <?PHP print('"'.$gaid.'"'); ?>;
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', gaid);
    gtag('config', gaid, {'custom_map': {'dimension2': 'Za'} });
    gtag('event', 'set_za', {'Za': <?php print("'".za()."'"); ?>} );
    gtag('config', gaid, {'custom_map': {'dimension3': 'Zd'} });
    gtag('event', 'set_zd', {'Zd': <?php print("'".zd()."'"); ?>} );
    </script>
    

    I’ve set this for automatic insertion, in the head, if the page = entire website.

    So although I’m seeing my hits in Google analytics, each hit is showing up 3 times! Why is this running 3 times for each page? I’m suspect it has something to do with adding to 2 custom dimensions – but I think I’ve done this per GA examples.

    • This topic was modified 1 year, 1 month ago by ocglimited.
    • This topic was modified 1 year, 1 month ago by ocglimited.
    • This topic was modified 1 year, 1 month ago by ocglimited.
Viewing 1 replies (of 1 total)
  • Plugin Author Artem

    (@webtemyk)

    Hi.

    Check how many times this code is inserted on the page . You may already have used this script somewhere

Viewing 1 replies (of 1 total)
  • The topic ‘Google Analytics script running 3 times on each page’ is closed to new replies.