How to see Google Analytic reports in the back-end
From TomatoCMS Documentation
How to register website with Google Analytic
- Go to Google Analytic website
- Click on the Access Analytics button
- Use your Gmail account to sign in
- Click on the Add Website Profile link
- Enter your website address in the text box under the Add a profile for a new domain section
Click on the Continue button
- At the tracking status page, you will see the tracker ID provided by Google Analytics.
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.





