How to see Google Analytic reports in the back-end

From TomatoCMS Documentation

Jump to: navigation, search

How to register website with Google Analytic

File:ga_step1.jpg

  • Use your Gmail account to sign in

File:ga_step2.jpg

  • Click on the Add Website Profile link

File:ga_step3.jpg

  • Enter your website address in the text box under the Add a profile for a new domain section

File:ga_step4.jpg

Click on the Continue button

  • At the tracking status page, you will see the tracker ID provided by Google Analytics.

File:ga_step5.jpg

Also, it provides the Javascript code section which need to be inserted on every pages.
The section 2 will show you how we do it.

How to add the Google Analytic tracker code to website

After registering your website with Google Analytic, you will get the Javascript code like this:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17059757-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 code sections have to be shown on every pages we need to track.
In order to do this, open the template file, /application/templates/default/layouts/default.phtml, then add the code before the </head>:

/application/templates/default/layouts/default.phtml

...
<head>
    ...
 
   <script type="text/javascript">
   //<![CDATA[
   Tomato.Core.Widget.Loader.baseUrl = '<?php echo $this->baseUrl(); ?>';    
   //]]>
   </script>
 
   <script type="text/javascript">
   var _gaq = _gaq || [];
   _gaq.push(['_setAccount', 'UA-17059757-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>
</head>
...

How to see the Google Analytic report inside TomatoCMS back-end

From 2.0.7 version, you can see the Google Analytic report inside the TomatoCMS back-end.
Google Analytic will require your authentication. There are two methods to do this:

  • Manually method:

Every time you use this feature, you have to sign in Google using your Gmail account.
After signing in, you have to grant access for the website to get the data from Google Analytic.

  • Automatically method:

Open /application/modules/seo/config/config.ini file, and add your Gmail account:

[google]
username = "your_gmail_address@gmail.com"
password = "your_gmail_password"

From now on, you don't have to make any authentication.

Personal tools