• Apologies if this has been asked before, but since google analytics upgraded to Universal, it has stopped working on my blog frankbukowski.com

    Logged on to my GA account and it appears to have upgraded itself to Universal, and says I need to paste new Universal tracking code into all my pages. Reading around the internet you get lots of different advice. Many say paste it into the header.php file just before the closing </head> tag, but I assume if I did that, it would be lost whenever the theme updates.

    I know Nico has provided a code snippet to be used with the google analytics code, in the functions.php file of a child them. And while
    I did create a child theme when I installed Customizr, as Nico recommended, I used the ‘one click’ option, so I only got a style.css file in my child theme. No functions.php file. I’m not a developer so I don’t really know how to create one. If it’s easy, I’d love to know how.

    Other people online say use a header and footer text widget to post the tracking code, while yet others say simply use a google analytics plugin, it’s all done for you. While the last option is a good fallback, I’ve got quite a few plugins already so am trying to avoid adding more unless I can avoid it.

    Be grateful for any opinions or advice on the best way to proceed.

    Thanks all.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi Frank, do you have a ftp access to your site?
    If yes, just a create a file named functions.php with just this inside:

    <?php
    /* Put your custom functions below */

    then upload it in your child-theme folder.
    Then go to Appearance -> Editor, and you’ll see the new file Theme Functions (functions.php) listed for the child-theme. Then you can edit that file there and put Nico’s snippet in it.

    I too have this issue and have been working on it today. I have added the functions files to my child theme. On my own initiative, I also added google-site-verification code to the functions file – and google accepts that. But does not accept the script.

    @kttour-360: It is considered impolite to interrupt another poster’s ongoing thread unless you are posting a solution or suggestion. As per the Forum Welcome, please post your own topic.

    Please accept my sincerest apology for interrupting this conversation with my own failed attempts to solve the exact same problem. I won’t make the mistake again of attempting to verify a potential problem, esmi.

    @kttour-360: These forums have guidelines. Please read them. As you will see, one of these guidelines – entitled Where to Post – specifically states:

    Unless you are using the same version of WordPress on the same physical server hosted by the same hosts with the same plugins, theme & configurations as the original poster, do not post in someone else’s thread. Start your own topic.

    Please abide by this.

    If it’s not too impolite of me @frankbukowski I would suggest, at least for temporary, trying a plugin called “Google Analytics” which injects the code. It’s different code that what my Google dashboard is recommending but it seems to be tracking the site now and accepting code.

    Best Wishes,

    [Unnecessary comments directed at forum moderator removed. Do not re-insert them!]

    Frank, please log into your GA account again and re-read that announcement. It says you can upgrade to GA universal, not that you must. Nor does it say that support for the “old” method is to be dropped any time soon.

    So, my advice is: if GA are important to you and your website, do not upgrade yet. Wait until eventual bugs are solved and until you have at least 3 plugin options or methods to insert the new tracking method. Most probably Google will develop a plugin featuring the new tracking method themselves.

    If however, you don’t care so much about the increased risk of incompatibility and want to make the switch now, select the tracking code for your domain from GA and save it as analytics.php in your child theme folder.

    Now save the following code as functions.php, also in your child theme folder:

    <?php
    add_action('wp_head', 'include_ga_tc');
    function include_ga_tc() {
    	get_template_part('analytics');
    }

    Don’t forget to disable the old tracking method (plugin/function/whatever you had)… You don’t want both methods mixed up.

    Thread Starter FrankBukowski

    (@frankbukowski)

    Thnnks all

    @d4z_c0nf, I believe I do have ftp access to my site at my web-host, I’ve just never used it before. (a web developer friend set up my WP site for me originally on another web host, and when I transferred to my current web-host, they transferred everything across for me). However I think it’s about time I bit the bullet and started getting some basic functionality with filezilla, so I can do simple tasks like this.

    @kttour-360, thanks v.much for you contribution too, which I appreciated. I’ll definitely bear in mind your suggestion of using the plugin, which I was also considering (except a different one – ‘Google Analytics Dashboard for WP’, which seemed the best from the ones I reviewed.

    @acub, when I logged into my GA account it appeared to have already been upgraded to GA Universal, without me doing anything. The ‘Admin’ page has the new three column layout – Account, Property, View. And under the ‘Tracking info’ dropdown menu I have the following options, which everyone says are only available in the new ‘Universal’ platform:

    Tracking Code
    User-ID
    Session Settings
    Organic Search Sources
    Referral Exclusion List
    Search Term Exclusion List

    I don’t remember getting any accouncement tell me I could upgrade or stay as the old custom look. I just logged on the other day and saw it had changed. Last time I logged on several months ago it was in the old custom look, and there was lots of user data in my ‘reporting’ section. Now I’m in the universal look, and there’s no data at all in my reporting section. Hence my need to paste in the new tracking code.

    GA isn’t critical to my blog, but useful. I’m intrigued that you counsel not upgrading yet, is it still considered beta? Thanks for the code snippet too. I’ve no idea where to find (and disable) the old tracking method. I probably need to get in touch with the developer friend who originally set up my WP blog for me, as he also set up my Google Analytics account for me at the time, back in 2012. He definitely didn’t use a plugin, though, it was just sent up as an old custom GA account, so he probably manually added the tracking code in php.

    No, it’s not considered beta. It’s just out of beta. Call me paranoid, but since I have to admin a lot of domains I have this tendency to wait at least two weeks after the launch just to see if any bugs show up.

    And no, your GA account is not upgraded to universal. All GA accounts are now compatible with the “universal” tracking method. But your account remained the same, they just added a few ads for the “universal” tracking method. You upgrade a website to “universal” when you change the tracking method for that particular website through any of the available means.

    The code you should save as analytics.php, should you chose my method to add the code to the pages of your website, is the one under Tracking Code.

    I am intrigued to find out you do not have any data. You should have. I do for all websites I track and haven’t upgraded any to the new tracking method, I can assure you it still works. Check if your old tracking method still works and that the tracking code gets printed in the page. Maybe that’s why you don’t have any data. Anyway, this is definitely a matter you should take to the one who has installed GA on your account (or responsible for that plugin, if you use one). Or, if you tracking code is in the page and does not work, you should ask for support at GA, though I suppose they’ll just advise upgrading to the new tracking method.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Adding google analytics tracking code’ is closed to new replies.