Tagged: theme-options
-
AuthorPosts
-
July 18, 2014 at 4:03 pm #293007
Google analytics code (placed using theme function) is not placed inside <head> tag as requested
July 18, 2014 at 4:17 pm #293020Hey pinzanoaltagl!
Please add your Google analytics code in Enfold theme options – http://i.imgur.com/OCejjUi.png
Best regards,
YigitJuly 21, 2014 at 11:02 pm #294065I, too, am having trouble with the GA snippet being placed before the </head> tag. I added the tracking code in the Enfold theme option as you indicate above, but it being placed almost at the bottom of my <body>.
My URL is http://www.atticfilmfest.org – am I missing something?
Thanks!
BillPS – I just saw another post, so I added the following – is this correct?
<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-33354906-1’]);
_gaq.push([‘_trackPageview’]);(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();</script>
- This reply was modified 10 years, 5 months ago by bjconcan.
July 22, 2014 at 4:23 am #294142Hi!
If you want to move the google analytics code inside the head tag, remove the ga code on the theme options then add this on functions.php:
function ava_ga() { $uacode = "UA-33354906-1"; // Set the UA code here, example "UA-33354906-1" $gacode = " <script type='text/javascript'> var _gaq = _gaq || []; _gaq.push(['_setAccount', '".$uacode."']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> "; echo $gacode; } add_action('wp_head', 'ava_ga');
Get your ga UA code, replace the default $uacode value. You can find it on this line:
_gaq.push(['_setAccount', 'UA-33354906-1']);
Regards,
IsmaelJuly 26, 2014 at 2:26 pm #296220I find this really confusing. Previous posts (and one my Kriesi) suggest just pasting the code in the Enfold Theme Options (as does Yidget above), but clearly this does not work anymore.
When creating a new Google Analytics account you are forced to get the Universal (UA) code and not the original GA code.
Is the Theme Option therefore redundant for new Google accounts? It’s certainly confused me (I’m just a novice) :)
I have added the code and the Status is: Tracking Not Installed
When it is working, should I expect to see myself via the Real-Time Overview Report?I know how to do the above and edit the functions.php but I have a question about that. I followed the instructions for creating the Enfold Child Theme and now have that working. Do I copy the whole of the functions.php from the original theme directory and put it in my Child Theme with the code above? Or can I create a new functions.php file with just the code above? The question i am asking is, does WordPress read the child functions.php file first and then add what ever information is in the main theme functions.php ? Or does the Child Theme functions.php completely overwrite the main file?
Sorry, just a noob here (but I am building my 5th Enfold site) Hope you understand the questions and can help. I am sure it will help clarify for others too.
July 26, 2014 at 4:51 pm #296244Hey!
In fact it should be possible to use the “Google analytics” option field on the Enfold > Theme Option page. If you want to embed the code in the head area just add this code to the child theme functions.php file:
add_action('after_setup_theme','avia_change_analytics_pos', 10); function avia_change_analytics_pos() { remove_action('wp_footer', 'avia_print_tracking_code'); add_action('wp_head', 'avia_print_tracking_code'); }
You don’t need to copy the parent theme functions.php code – just create a new functions.php file, add the
<?php
tag to the very top of the file and then use the code I posted above.
Regards,
PeterJuly 29, 2014 at 1:01 pm #297268Hey, I have just checked the Analytics account and I have history AND I can see myself live on the site. I guess it just needed time to update everything. I didn’t make any changes so will leave it as it is.
Thanks for the clarification though.
H.July 30, 2014 at 3:18 am #297537Hi!
I actually tested the same code as Dude suggested before but it doesn’t work on my end. Not sure why it works on his installation. So for everyone who wants the ga code in the header, you can try either of the suggested snippets above.
Regards,
IsmaelDecember 14, 2015 at 6:07 pm #552524Hi!,
I´m adding this snippet to the functions.php file, but I have two questions.
add_action('after_setup_theme','avia_change_analytics_pos', 10); function avia_change_analytics_pos() { remove_action('wp_footer', 'avia_print_tracking_code'); add_action('wp_head', 'avia_print_tracking_code'); }
1) I don´t have a child theme, just Enfold, so I´m adding it to the main functios.php file. Is that correct?
2) Doing it that way, I´m having the analytics code in two places, in the HEAD and at the end of the html. Why?
Regards,
ChrisDecember 15, 2015 at 10:14 am #552877Hi,
Is pasting your analytics code the theme backend not working? Your function should not be necessary. Please send us a temporary admin login so that we can have a closer look. You can post the details in the Private Content section of your reply.
Best regards,
Rikard- This reply was modified 9 years ago by Rikard.
August 31, 2016 at 10:59 pm #680358I created a gogle maps api key and placed on e-panel but i still see the message sayin i need to place an api key there and gg maps does not work. My website was already verified by google
August 31, 2016 at 11:10 pm #680361Hi,
Can you post the link to your website please?
Regards,
JosueFebruary 1, 2018 at 8:50 pm #906452Hi.
In Theme Options, there is no longer a place to insert the G/A code. This change seems very recent – how do we place G/A tracking code now?
The only boxes in Wp Admin/Theme options focus on logos, favocons?
February 1, 2018 at 8:56 pm #906457Hi.
In Theme Options, there is no longer a place to insert the G/A code. This change seems very recent – how do we place G/A tracking code now?
The only boxes in Wp Admin/Theme options focus on logos, favocons?
February 2, 2018 at 6:46 am #906656February 10, 2018 at 11:34 pm #910684Is there any chance to avoid tracking of logged in admin users? I don’t want to see myself in Google Analytics and am not working from a fixed location with a steady IP address that I could filter from my Analytics data.
February 12, 2018 at 6:05 am #910909Hi Christoph,
That is not up to your theme to decide, but I think that you can set that in your Analytics account? Or maybe there is a plugin to control that?
Best regards,
RikardFebruary 12, 2018 at 2:03 pm #911104Okay. So the Analytics function is quite useless here when I can’t avoid tracking logged in admin users…
February 13, 2018 at 4:37 am #911485January 23, 2020 at 3:43 pm #1177668Hi there,
I’m confused by this discussion. I want to insert two Google Tag manager snippets. One in the head as high as possible and the other after the Body.
I’m not operating a child theme.
Thanks
- This reply was modified 4 years, 11 months ago by ADMan. Reason: typos
January 23, 2020 at 4:00 pm #1177677Hi,
@ADMan Please refer to this post – https://kriesi.at/documentation/enfold/add-custom-js-or-php-script/ :)
Best regards,
Yigit -
AuthorPosts
- You must be logged in to reply to this topic.