[Resolved] Universal tracking code Google

Home Forums Support [Resolved] Universal tracking code Google

Home Forums Support Universal tracking code Google

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #262587
    Karim

    Hello Tom,

    I am having an issue with: https://www.rbdakgootreiniging.nl

    I wanted to add the universal tracking code to track Google analytics. Instead of adding it to each page seperatly i wanted to use the GP Hooks. So i implemented the code in the wp-head section, but then i saw the code from the front side of the site(see link for attachment), and after deleting the code totally, i keep seeing this small piece of code still from the frontside above the header(see other attachment)

    I had to restore a backup eventually.

    What did i do wrong to get the universal tracking code working?

    http://i65.tinypic.com/2em3qkk.jpg
    http://i63.tinypic.com/wb6wzc.jpg

    #262604
    Roberto Enrique

    You should add the tracking code inside <script><!--your google tracking goes here--></script> tags.
    I do this very frequently.

    #262620
    Karim

    Hello Roberto,

    Thanks for the reply sir:)

    So, i can use the GP Hooks “wp-head”?

    And if i understand you correctly, my code will look like this:

    <script><!–<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’,’https://www.google-analytics.com/analytics.js&#8217;,’ga’);

    ga(‘create’, ‘UA-11111111-16’, ‘auto’);
    ga(‘send’, ‘pageview’);

    </script>–></script> tags.

    It starts with 2 times <script> and ends 2 times with </script> ?

    This is new for me

    Thanks again

    #262622
    Roberto Enrique

    not really, mine looks like this:

    
    <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','https://www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-XXXXXXX-1', 'auto');
      ga('send', 'pageview');
    
    </script>
    

    where did you get your code from?

    This is where i pick it from analytics dashboard:

    View post on imgur.com

    #262628
    Karim

    Yeah, i also took my code from there, but i thought i had to put the code inside the code you sent in the previous comment.

    This is what my code looks like from my universal 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’,’https://www.google-analytics.com/analytics.js&#8217;,’ga’);

    ga(‘create’, ‘UA-xxxxxx-16’, ‘auto’);
    ga(‘send’, ‘pageview’);

    </script>

    But when i pasted this code in the wp_head hook i got the problem i started this topic with

    #262639
    Tom
    Lead Developer
    Lead Developer

    If you copy the code exactly as it is when Google gives it to you, you won’t have this issue.

    It needs to be inside <script></script> tags, but only one set of them.

    #262718
    Karim

    I did it again, and now it seems to work well. I have no idea what went wrong the 1st time.

    I thanks you both alot:)

    Cheers

    #262775
    Tom
    Lead Developer
    Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.