Friday, 21 September 2012

How to Generate Google Analytics Tracking Code [Theory and Video Tutorial]

Today we shall be looking at how you can generate your blog Google Analytics tracking code using the theoretical and video approach. I decided to make this post following the experience I had when I was fond of changing templates on my blogs.

Each time you make changes or upload a new template to an existing blog containing a Google analytics code, the change affects the tracking code, which means you will be having problem of tracking the activities on your blog.

Now because you only get to generate the tracking code the straight way only when you are adding the code for the first time, it is not the same when you want to generate it again. Hence, this post will help you learn the means of generating your blog Google analytics code.

Step 1: Go to http://www.google.com/analytics/ and sign in using the email address you used to open your blog

Step 2: Once you are logged on your account, your account profile will display just like the screen-shot below"

As indicated on the screen-shot above, click on +Add new profile" and then proceed to the next step

Step 3: The next step will prompt you to choose an existing profile or create an entirely profile to generate the code. Select the "add a profile for a new domain" option and fill enter your blog URL in the form www.yourblogname.com (in my case it would be www.naijatechblog.com) See the screen-shot below:



Step 4: Also follow the arrows as they have been added on the screen-shot above to complete the process. Select the "add a profile for a new domain > type in the domain name or URL of your blog > type in your country and finally hit the "Continue button below it.

Step 5: The Google Analytics Tracking Code will immediately be generated for you which will look like the one below:

<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try{
    var pageTracker = _gat._getTracker("UA-xxxxxx-x");
    pageTracker._trackPageview();
    } catch(err) {}
    </script>


Step 6: Paste the code immediately before the </body> tag or immediately before the <head> tag of your page, make sure not to alter the code, leave it the way it is.

Allow Google some hours to gather data from your blog, so that your blog's status can be ascertained.

If you find it hard following my steps above (which I doubt you will have) then proceed to the video tutorial below:
 

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35006320-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>

No comments:

Post a Comment