Reputation: 3040
I'm trying to set 5 custom variables for Google Analytics like so:
<script>
//<![CDATA[
var _gaq=[["_setAccount","UA-XXXXXXXXX-X"],["_trackPageLoadTime"]];
_gaq.push(['_setCustomVar', 1, 'categories', 'News', 3]);
_gaq.push(['_setCustomVar', 2, 'tags', 'something, another, passbook, iphone, ipod, ios6, insider, egift, more things, some other stuff', 3]);
_gaq.push(['_setCustomVar', 3, 'productcount', 0, 3]);
_gaq.push(['_setCustomVar', 4, 'isvideo', 'false', 3]);
_gaq.push(['_trackPageview']);
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));
//]]>
</script>
I think I've followed all the rules by adding no more than 5 custom vars before the call to trackPageView, but they still don't show up in Google Analytics.
Upvotes: 3
Views: 1171
Reputation: 7270
(serve from something that's not localhost or file://)
<html><head><title>Demo</title><script>
var _gaq=[["_setAccount","UA-XXXXXXXXX-X"]];
_gaq.push(['_setCustomVar', 1, 'categories', 'News', 3]);
_gaq.push(['_setCustomVar', 2, 'tags', 'something, another, passbook, iphone, ipod, ios6, insider, egift, more things, some other stuff', 3]);
_gaq.push(['_setCustomVar', 3, 'productcount', '0', 3]);
_gaq.push(['_setCustomVar', 4, 'isvideo', 'false', 3]);
_gaq.push(['_trackPageview']);
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));
</script></head><body><h1>Open your console</h1></body></html>
Upvotes: 5