How does the analytics id need to be added

Will this plugin still work if the Google Analytics code is being added through Google Tag Manager? It's been about 24 hours and I haven't seen the custom segments show up on the analytics site yet. Is there a way to manually input the Google Analytics Id into this plugin?

  • Jude

    Hi @Matt

    Hope you are doing great !!

    1) Yes it should work Google Tag Manager.
    2) The analytics code must be inserted into the themes you are AB Testing on. Alternately you can use a third party plugin to do this.

    Here is how I add the code on my sites.

    function GA_tracking_code () {
    ?>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-XXXXXX-2', 'auto');
      ga('send', 'pageview');
    
    </script>
    <?
    }
    
    add_filter( 'wp_footer', 'GA_tracking_code' );

    Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one. Also replace the code with your own tracking ID.

    Cheers
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.