we have pages that has tags. we want a report based on these tags. Those tags are around 0~20 for one page. how can we implement in analytics.
view page: tags
15 Page1 : apple, pine, five
3 Page开发者_运维技巧2 : tree, pine, sea, shore
9 Page3 : pine, sea, five, bike
we want to see how many tags seen like :
tag view
apple 15
pine 15+3+9=27
five 15+9=24
tree 9
sea 3+9=12
I think I can arrange shows but I cant define more than five custom variable.
One way to do this is to use a single custom variable slot… lets use #5 for this example:
It’s worth keeping in mind this important point: “The total combined length of any custom variable name and value may not exceed 64 bytes.” http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#usage
So that means that we need to keep the amount of data you send to Google as small as possible if it’s all going to fit in a single custom variable. Because a single tag name can contain quite a few characters I’d recommend using the tag’s ID number instead. Most likely your database is storing all your tags and each tag does have a primary ID that corresponds to it. Example:
1 = apple
2 = pine
3 = five
4 = tree
5 = sea
6 = shore
7 = bike
If you pass only the ID over to Google Analytics then you’re going to save a lot of space and give you more room to fit all the possible tags that a single page might have been tagged with.
Now lets look at some code…
_gaq.push(['_setCustomVar',
5, // This custom var is set to slot #5.
'tags', // The name of the custom variable.
'1-2-3-,', // Sets the value(s). Here is where we pass the tag IDs. In this case we know these equal apple, pine, five
3 // Sets the scope to page-level.
]);
And as another example..
_gaq.push(['_setCustomVar',
5, // This custom var is set to slot #5.
'pageTags', // The name of the custom variable.
'4-2-5-6-', // Sets the value(s). Here is where we pass the tag IDs. In this case we know these equal tree, pine, sea, shore
3 // Sets the scope to page-level.
]);
You can then filter in Google Analtyics to find page views that have specific tags. Example: If you only want to find page views tagged with “pine” then do a search for “-2-”. Note that I’m using a hyphen after every number. This helps us separate the numbers. If you want to run more complex filters in google analytics you can get more complex using regex as your filter criteria.
This should work, just keep in mind that the values + the name of your custom variable can not be longer then 64 bytes. So you need to keep your tag ID numbers as tiny as possible (2 digits max probably) and try not to go over 6 tags per page.
Example: Custom Variable Name: Tags Values: 1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20-21-22
Your custom variable name above takes up 4 bytes and your values take up another 57 so your total bytes used is just under the maximum 64 bytes. If you start getting into three digit tag IDs then you're going to quickly shrink your options on how many tags you can pass.
Hope this helps!
精彩评论