Tagged: 

Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #293007

    Google analytics code (placed using theme function) is not placed inside <head> tag as requested

    #293020

    Hey pinzanoaltagl!

    Please add your Google analytics code in Enfold theme options – http://i.imgur.com/OCejjUi.png

    Best regards,
    Yigit

    #294065

    I, 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!
    Bill

    PS – 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&#8217; : ‘http://www&#8217;) + ‘.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.
    #294142

    Hi!

    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,
    Ismael

    #296220

    I 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.

    #296244

    Hey!

    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,
    Peter

    #297268

    Hey, 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.

    #297537

    Hi!

    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,
    Ismael

    #552524

    Hi!,

    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,
    Chris

    #552877

    Hi,

    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.
    #680358

    I 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

    #680361

    Hi,

    Can you post the link to your website please?

    Regards,
    Josue

    #906452

    Hi.

    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?

    #906457

    Hi.

    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?

    #906656

    Hi Aquanaut40,

    You can add it under Enfold->Google Services.

    Best regards,
    Rikard

    #910684

    Is 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.

    #910909

    Hi 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,
    Rikard

    #911104

    Okay. So the Analytics function is quite useless here when I can’t avoid tracking logged in admin users…

    #911485

    Hi,

    Like I wrote earlier; it’s not up to us to decide that.

    Best regards,
    Rikard

    #1177668

    Hi 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
    #1177677

    Hi,

    @ADMan Please refer to this post – https://kriesi.at/documentation/enfold/add-custom-js-or-php-script/ :)

    Best regards,
    Yigit

Viewing 21 posts - 1 through 21 (of 21 total)
  • You must be logged in to reply to this topic.