Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Tracking Multiple Template with segmented reports for Google Analytics

Tracking Multiple Template with segmented reports for Google Analytics

Hi Stephen, I've noticed there is no thread yet about metatemplate and google analytics report so I decided to give it a try!

I have 5 different template I use for 5 different customer profile. I need to track data on each of them to verify my strategy and act upon it.

Having just the same general standard tracking code on each template wont give me contextual data on each template.

I need to create a unique code for each template and be able to link it to a unique segmented report for that template, collecting only the data of one template at a time.

Any ideas?
Cheers.
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

Ok, will look at this in the morning. It's basically going to be using the Google Analytics API with a bit of javascript that you will modify and add to each template. I haven't looked at this for a while so I forgot how it works exactly. Is it something that you can work out yourself from the GA help documentation?

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

Great! I'm glad you can help cause I have no clue where to start with the GA document. It's very general and I always need a few cue to start since I'm totally illiterate in coding.

Many thanks, I'm sure this post is gonna please a lot of people...
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

Ok, I've been reading through the GA documentation, and have the following suggestion for how to track your different templates with GA "custom variables".

Reference: http://code.google.com/apis/analytics/d … ables.html

Ideally you would have a plugin in Joomla to add this to each outgoing page, but failing that it's not hard to add the following code to each of your templates.

(1) get hold of your GA tracker code. It's something like UA-XXXXX-X

(2) remove existing GA tracking Javascript from your template, or disable any other extensions that add it. You're going to add some Javascript directly to each template.

(3) put the following piece of JS code into each of your templates, just above the </head> tag:

  <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']); // <== put your GA code here
    _gaq.push(['_trackPageview']);
    _gaq.push(['_setCustomVar',
      1,
      'Template',
      'MyTemplateName' // <== customise here for each template
   ]);
   (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>


(4) all going well, after a few hours you should be able to see some segmentation occurring in Google Analytics


As I said, I haven't tried this and I am not a GA expert, but as far as I can see from the documentation this should work.

Please write back with the results!

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

OK thanks Stephen, I did all that with a slight variation. I did put the code on every of the template's index.php but just before the last </body> tag after the last </div> of the body. I heard its better to it that way in order not to slow down the experience of the user with all this script loading before the </head>.

I created seperate profile in my GA account for as many templates. I did configure a filter for each using the "Include" + "Custom Variable 1" + "CustomNameTemplate". I dont know if its gonna work.

I figured out from reading that you've used the "variable slot #1" in your coding so I guess its the "custom variable 1 filter" that's gonna retreive the name of the template in the filter inclusion.

I will let you know what happens when I get data...

Cheers,
Alex

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

Regarding where to put the GA script: apparently this latest version of the GA script is now recommended to put in the <head> section. This is because it's asynchronous - meaning that even though it's put in early, it only executes later. But there's not much wrong with where you put it, either.

I can't wait to find out if this works now!

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

OK the asynchronous information is very valuable. As the whole </head> or </body> has become a myth after all...

My account haven't gotten any data labeled "template" yet. The usual general report still collects data, but the new one I created with an inclusion filter, not yet.

I will wait another day and check it again... standby.

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

Alex - have you got any data from yours yet? I've just put this onto my site as well so I'll see if I can get any data out of mine. I'll report back in 24 hours or so.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

Hi Stephen, no I got nothing. There must be something wrong I did. There's no data in any of the new custom report I did and nothing can be tracked anywhere in custom variable in "Visitors".

I got some reading on my usual reports though, there is some activity, but the template based tracking doesn't work.

I will wait until you have something on your end, no rush.

Cheers,
Alex.

atherrien
Modder Extraordinaire
ranks
useravatar
Offline
140 Posts
Administrator has disabled public posting

Re: Tracking Multiple Template with segmented reports for Google Analytics

ok, hopefully I'll see something tomorrow sometime. Will let you know.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10091
Newest User:
lamanaudio
Members Online:
3
Guests Online:
129


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked