Adding Google Analytics to Customizr 70

If you’re not a developer, you can refer to this complete documentation on setting up your Google Analytics tracking code with a plugin.


Here’s a quick snippet to add Google Analytics tracking’s code to your website.

Where to copy/paste this code? => in your functions.php file of a child theme. I strongly recommend you create a child theme. Download a start-up child theme here.

Everything you need to know about child theme with Customizr here.



  • ben boldt

    Can the alternative method of adding the google code in the header section be used? If it can what need to be done?

    Thank you

  • ben boldt

    Hello again, My site using the customizr theme is a subdomain of another site. The subdomain site does not have the “function.php” file showing. Can the google meta tag still be added somewhere so that the site can be verified?

  • Paula


    I had done what you put on this post and when I save the functions.php with the new code the page can not be uploaded, and I can´t access to the wp-admin. I don´t know what happenned. Please I need some quick help, I am a little bit worried.

    Thank you so much.

    • Nicolas

      Hi Paula, there must have been some error in the code : upload a new clean version of your functions.php to your server.
      Hope this will help.
      PS : if you still have issues :
      1) always make a backup of your files before starting to develop.
      2) please continue this discussion on the WordPress forum

  • Paula

    Thank you so much Nicolas!!
    And Congrats for the amazing theme! :)

  • John

    My website is I followed the code snippet by nikeo, and cannot seem to get tracking installed. Here is the code, placed in a functions.php child theme:

  • Stamatis Kanatas

    Hello!Since i upload my site from localhost to internet host i cant edit the functions.php file because i dont have the permissions…What goes wrong?

  • Sandra

    Could someone add a more detailed example of where to add the code in the functions.php file? I’m not very knowledgeable in .php. Thanks!

  • ElectricFeet

    Hi Nicolas, could you update to say “Use the following code in the functions.php file of your child theme:”
    Someone on the forum tried adding it to the theme’s function.php.

  • ElectricFeet

    Make that *2* people on the forum who added it to the theme’s function.php :-(

    • Nicolas

      Done! Thanks

  • david

    I installed a plugin to do that, but, visits from mobile version don’t work
    How to resolve?

    • Nicolas

      Hi David, you might post a thread on the plugin’s forum about that.

  • ebwally

    I”m so confused! I’m just a layman with a dream. Hi Nicolas – thanks for your beautiful theme. I love it – though I’m not using it to its full potential I’m sure. I”m writing because my site does not come up when you google Brooklyn Arts for Kids – I have tried to verify and do what Webmaster Tools suggested but nothing is working. Help! I don’t know where to add tags to a page or how to easily alert Google of our whereabouts. Thanks for any and all help. With best wishes, ebwally

  • Richard

    Thanks Nicolas I’ve spent half a day scouring the net trying work out how to get verified. I should’ve came here for advice first. 😉

    Can I use the same snippet for Bing and Alexa?

    • Nicolas

      Hi Richard, yes this should also work.

  • Rick Cantu

    Hello. Newbie at HTML here. I added the following to header.php as Google wanted me to add (and maintain) the code below in the header section of my website for domain verification purposes. When I added the code as shown below, the text boxes in the sliders were thrown out of position (they were no longer appearing centered). Once I removed the code, everything looked normal again. What am I doing wrong? I played with some plugins that were supposed to lead to Google reading meta tags on my site but they didn’t work. Thanks for your help!

    ***CODE ADDED***


    * The Header for Customizr.
    * Displays all of the section and everything up till
    * @package Customizr
    * @since Customizr 1.0

  • Sean Smith

    Does the same go for using the Google Webmaster Tools code for verifying ownership of a website? Should I use the same code and just replace the analytics … with the ?

    Google Webmaster Tools tells me to place the within the of my homepage. But of course the head is added to the header.php via a hook in Customizr theme so I’m not exactly sure where to put this code.

    Thanks in advance for any advice.


    • Nicolas

      Hi Sean, I confirm that you can use the same snippet to handle the Webmaster Tools verification.

      You can just add the conditional code to display this code only on home page, with the Customizr built-in helper : tc__f(‘__is_home’).


  • Eloy

    Thanks for all your hard work. The Google analytics work great and your theme is very good.

    • Nicolas

      Thanks for your feedback @Eloy. Thanks for the donation too. Much appreciated!

  • Belqadi

    I hope this email finds you well. Many thanks for your help. Great Work. I love it!! I have a question please. Many folks waiting this. Could you please demonstrate where and how I insert the Google Tag Manager Snippet into your Child Theme?

    Please note, I don t want to use a Google Tag Manager plugin for that as I believe it has some limitations. It is important as Google Tag Manager will cover everything: Analytics, Marketing, Remarking and more. Please note I installed Customizer Child with only style.css created.How Can I create Functions.php with Filemanager plugin? Could please show me how in simple steps ? Sure it will be a great help for me and many other. THE FOLLOWING is Google Tag Manager Snippet.

    new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],

    I am impatient to hear your help.
    Best of regards and many many thanks for everything in advance.

    • Pat Camillo

      I am also really struggling with trying to set up google analytics. I installed the child theme plug in as recommended with no problems. However, it appears that if I activate that, then the parent theme is inactivated – so I’m confused about that. I have my code for google analytics to insert and apparently I need to insert it into function.php but for the life of me I can’t find that anywhere! ANy help would be greatly appreciated!!!

      • Nicolas

        Hi Pat,
        The functions.php file is located in the child theme in the following path of your website : wp-content/themes/customizr-child.

        If you are new to Customizr (and WordPress), you might want to read this short guide on how to customize Customizr.

        I would also strongly recommend that you take a look to the following resources :
        1) the Customizr theme documentation
        2) the FAQ
        3) how to make a research in the Customizr user’s forum
        4) the Customizr code snippets

        If you still have issues then post a new thread in the the Customizr user’s forum and we’ll do our best to help you.

        Hope this will help !

        • Pat Camillo

          Thanks so much Nicolas for responding! I’m a qualitative researcher so this kind of coding etc isn’t really a match for me but I need to do it!! I will read through all the resources and hopefully figure it out but grateful to know there is help here :).

  • Joe


    When I use the Editor it allows me to choose between themes. If I choose Cutomizr it shows me all the editable php files including functions.php for the Customizr theme. However, as we know we should not enter the Google Analytics code there, because it will disappear when a theme update is made.

    However the problem is that when I choose my child theme from the list of themes to edit, the Editor only shows me one editable file, style.css. This is fine for making style changes but it doesn’t help in cases where files like functions.php need to be edited in the child theme. Is there any change I can make so that the entire list of editable files will show up in the Editor for the child theme too. If this is something users cannot do, then perhaps you should consider making a change so that at least the functions.php is editable in the Editor for a child theme.

    Thank you for a great theme.


  • Joe Gallop

    Okay, I got it to work. The solution is the same for inserting Google Tag Manager Code or Google Analytics Code. Here is what you do:

    1. Create a text file called functions.txt on you desktop and paste the following code into it:

    2. Go to Google Tag Manager or Analytics and copy the code you want to insert.
    3. Select the line in your new file that says:

    then paste the Google Code.
    4. Save and close the functions.txt file.
    5. From your desktop rename the file: functions.php
    6. Open an FTP client or whatever file manager your host provides for your server.
    7. Navigate the files in your website’s directory until you find your child theme’s directory. It may be along a path like this:
    8. Copy the functions.php file to your child theme’s directory.
    9. Now in a browser open your website, and use the browser’s view source code function to view a page on your website.
    10. Use the find function to search on the page for the

    11. Somewhere (about 10 lines or so) below the head tag you should see your inserted Google Analytics or Tag Manager Code.

    Hope this helps.

  • Joe Gallop

    Step 10 above should say: Use the find function in your browser to search on the page for the word “head”. This should take you to the head tag.

  • Joe Gallop

    Sorry not sure why the code wrapping didn’t display all of the code in step 1 above. Here it is again:

  • Joe Gallop

    For some reason the code wrapper is only showing part of the code. I’ll try again with a shortened version of the code for step #1 above:

  • Joe Gallop

    Nicolas sorry just wipe out all these attempts. I can’t get the code wrapper to display my code.

  • Blake O’Ruairi

    Hi all.
    Hopefully this wont be out of place to ask as it does directly relate to adding Google analytics/Universal Analytics.
    When I was verfiying this site I’m working on and before I’ve added the customizr child theme to work with (Thank You, awesome piece),
    I used the “Add CNAME” method to verify ownership (i was already in Cpanel, hadnt done that method before, so..) of the site for Google analytics.
    Will i still need to add a code snippet to the child theme, per examples above, to get full Analytics, or will the CNAME method above work fine?
    Sorry if its off thread track, thought just hit me~
    Thanks All!

    • Nicolas

      Hi Blake,
      you’ll have to add the javascript code to get your Google Analytics working.

  • Patricia Camillo

    I’ve been struggling for almost a month now trying to add Google analytics to my site. I don’t know any code at all! So even when I read about inserting the code into the php function – I have no idea what you are talking about…….I was able to insert the analytics code very easily when I constructed a different website years ago using network solutions – so I am finding this extremely frustrating and time consuming. I finally found someone who told me to do the following – but I still don’t see it active……although it might take 24 hours. This is what I was told and I would appreciate your thoughts about this approach:
    Go to the “appearance” and click on “widgets”. Choose the text widget and move it to the “Footer Widget Area One”. Insert the code in that box under “Title” and hit “Save”.
    Is this a viable way to get analytics on board with this site? I was told that widgets are not changed with updates and that it shouldn’t be a problem.
    I greatly appreciate your response!

  • jacob

    Help, I received this error after updating functions.php, my website is down!

    Parse error: syntax error, unexpected ‘<' in /home/content/p3nexnas06_data02/18/2152918/html/wp-content/themes/customizr/functions.php on line 55

    Before made any changes or altercations to functions.php, I copied all the code from functions.php to notepad. I then restored all of the original data from notepad to functions.php. I am still getting this same error. Any ideas what I did or how I can fix this?

  • jacob

    Please disregard the above post…I just had to log into the FTP and reupload the backup…

  • Anne James

    Posted this code snippet and my tracking code into the functions.php file of the child theme, and I’m getting a white page with this error: Parse error: syntax error, unexpected ‘}’ in /home/zymboleditor1/public_html/wp-content/themes/customizr-child/functions.php on line 18
    Any thoughts?

  • Hillary Johns

    I tried uploading the Child Theme and everything look great… until I got this nasty message after putting in my Google Analytics.

    Fatal error: Cannot redeclare my_analytics() (previously declared in /home/alpineva/public_html/wp-content/themes/customizr-child/functions.php:22) in /home/alpineva/public_html/wp-content/themes/customizr/functions.php on line 71

    How do I fix this?! A little freaked out right now.

    • Nicolas

      You seem to have declared a php function twice. In this kind of situation, you’ll need to re-upload a clean functions.php file to your FTP server.
      Hope this helps,

  • Travis

    I followed the directions to install GA and it completely broke my site. I can’t even access my child theme to fix what happened. This is the error I get:

    Parse error: syntax error, unexpected ‘<' in /home/uoalogin/public_html/wp-content/themes/customizr-child/functions.php on line 24

    Please Help!

  • Travis

    I fixed it!

    • Nicolas

      Hi, thanks Travis.
      Could you please quickly explain how you did fix this ?
      Thanks (useful for users facing the same issue !)

  • Roman K.

    Hi Nicolas!

    Since WP 4.0 this snippet doesn’t work anymore.
    When I add this code to function.php of my child theme the site doesn’t work at all.

    How and where should I add the google now?

    Thank you!

  • ulya

    Hi Nico,
    I can’t found Child Themify botton after activate this plugin,
    Thanks for answer

    • Nicolas

      Hi Ulya,
      Did you try to use the Customizr Child theme, it may be simpler to use.
      I hope this will help,

  • Antonis Kioupliotis

    Hi there, I run a multisite under customizr, so far everything’s fine, but since Google Analytics by Yoast does not work properly anymore, I’m looking for a non-plugin-solution in order to have separate readings for both sites. The problem is that I only have one function.php file in child-theme and two ‘UA-xxxxxxxx-yy’. Any idea how to fix it?

  • Ana Castro

    Hello community, I need your help. What code I need to add to my functions file. php my son cutomizr theme google analytics to measure the comments of my blog ?, thanks in advance

    • Antonis Kioupliotis
      • Ana Castro

        I have already inserted the tracking code in the file functions son and my theme works. I am now setting goals google analytics and one of my goals is to measure the comments of my blog, the question is what code I need to insert into my theme for google analytics measure the comments of my blog?

  • ANa

    hello, how can I modify this code to add it to my theme functions.php file child?.thanks in advance

    function disqus_config() {
    this.callbacks.onNewComment = [function() _ga.push([‘trackevent’,’formulario’,’enviado’,’]);


    Don’t work
    I have customizer pro 1.0.10 on WP 3.5.1
    adding the code on function.php, the page is white and the site don’t work.

    i tried :
    function my_analytics() { ?>
    alert(“a”) )

    don't work. what solution I can try?

    • Nicolas

      Hi Deborah,

      Thanks for getting in touch !

      As a pro user, would you mind opening a new topic in the pro support forum about this ?

      Our support team will do its best to help !

  • Pratik Sinha

    Is it really necessary to install child theme? Dont you have some other way to make it more simpler for adding Google Analytics code?

    Please help me out with installing analytics code for different search engine for this theme, I am stuck and don’t know how to add the code as it is crucial for my website. I am skeptical of adding something extra as website speed is of utmost importance

  • Caro

    Hello, I’m triyng to pass GA code by functions.php, i’m not php coder at all, so i have no idea what’s wrong, no matter what I do, the “Warning: Cannot modify header information – headers already sent by …” appears.

    I really need some help here, please :)

    The actual location of the site is:

    And this is my code:

    I’ll be doing changes, so may be site will not appear or you’ll find a plugin solution (wich i don’t want) mean while.

    Thanks in advance for read me and for any help you can give to me :)

    • Pratik Sinha

      I will strongly recommend you to install this plugin instead of creating another child theme.

    • Rocco Aliberti

      Hi Caro,
      you can open a new topic here.
      Copy the whole content of your child-theme functions.php (the not working one) in and then put the link in your topic.
      Most likely is some small error in the code.


      to Pratik Sinha:
      she already uses a child theme, why do you say “another child-theme” ? 😀

  • Suresh Jaladanki

    With Customizr theme, Is there a recommended approach for setting up Google Analytics re-marketing Tag?
    I have currently configured my website for analytics, referring the code as published on this article. It works great, but looking for approach to embed remarketing tags.

    Thank you,
    Suresh Jaladanki

    • Nicolas

      Hi, what are the re-marketing tags? could you provide an example ?
      Thanks :)

      • Suresh Jaladanki

        Thanks for your reply,
        I was looking at setting up google re-marketing tag for retail on our website.
        This what i was trying to accomplish

        However, I am not looking at it anymore as there are restrictions in setting up the same for healthcare.
        Thank you for this great theme

        Suresh Jaladanki

        • Nicolas

          Ok got it. Thanks :)

  • Marius

    Hi Nicolas, and thank you for the snippet.

    I have to ad the meta tag for the google website verification in the tag of the index.php

    Can I use this snippet for this too, as it is?

    Thank You!