-
AuthorPosts
-
September 27, 2017 at 9:38 pm #857708
Google Analytics states the following
This is the Global Site Tag (gtag.js) tracking code for this property. Copy and paste this code as the first item into the <HEAD> of every webpage you want to track. If you already have a Global Site Tag on your page, simply add the config line from the snippet below to your existing Global Site Tag.
However, your Google services section inserts it at the bottom of the page. Is this a problem?
September 28, 2017 at 6:38 am #857877Hey xuamox,
I’m not sure to be honest, does your Google service work or not? Please post a link to your site if you should need any further help.
Best regards,
RikardSeptember 29, 2017 at 2:36 am #858285Yes, Google Analytics works fine.
I was just more worried about things like events tracking, etc.
Having some issues with events triggering from linksSeptember 30, 2017 at 5:50 pm #858787Hi,
You could use the plugin GA Google Analytics it gives the option to use the header or footer.Best regards,
MikeOctober 5, 2017 at 8:57 am #860485Thanks for the help
October 6, 2017 at 5:44 am #860848Hi,
Glad we could help. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardNovember 16, 2017 at 8:38 pm #877722Hi Rikard.
Can you please instruct on how to get Google’s new type of tracking code (Global Site Tag) to go into the Header and NOT the footer… using enfold’s functionality… and not by adding another plugin to do this.
Thanks
November 18, 2017 at 11:25 am #878487Hi splashmediagroup,
Here is the code you can put in your funtions.php
<?php add_action('wp_head', 'add_googleanalytics'); function add_googleanalytics() { ?> <!-- Global site tag (gtag.js) - Google Analytics --> <?php } ?>
If you need further assistance please let us know.
Best regards,
VictoriaNovember 18, 2017 at 7:26 pm #878614Hi Victoria
I’m not sure why you have the opening and closing php tags in your add_action code. All the other actions/functions I have in my function.php file don’t have this. I have one opening php tag at the top of the page, and then all my actions/functions go directly after it… none of which have their own opening and closing php tags.
If I use the code you provided I would have to close my existing opening php tag, directly after all the current actions/functions I have… and then use your code.
I could be very wrong, but please advise as this doesn’t seem correct.
Thanks!
November 18, 2017 at 8:05 pm #878624Hi,
You would not need the first opening tag, but you will need the last opening tag as there is a closing tag in the function This is because the js script that you get from Google Analytics has to be outside of the php code. Please see this article.Best regards,
MikeNovember 20, 2017 at 8:27 pm #879337Thanks for clarifying Mike.
Works fine.
November 21, 2017 at 4:34 am #879469November 21, 2017 at 6:18 pm #879860Good to close.
Thanks!November 22, 2017 at 12:08 pm #880198 -
AuthorPosts
- The topic ‘Google Analytics tracking code not in HEAD’ is closed to new replies.