hello
I would like track in GA all users according to their own CBsubs plan. For do that, GA allow the use of "custom variable" who must be implemented with javascript such this one:
Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_setCustomVar', 1, 'UserType', 'PlanGold', 1]);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(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>
In practice I suppose is necessary to fire this code with "onafterlogin" trigger and Auto-Action "Inline JS Code" and I tried but without success.
I found an alternative solution who consist to create a simple html page "goldplan.htm" with this code:
Code:
<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
window.location = "http://www.site.com/index.php?option=com_comprofiler&Itemid=126"
}
//-->
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_setCustomVar', 1, 'UserType', 'PlanGold', 1]);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(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>
<body onLoad="setTimeout('delayer()', 1000)">
</body>
</html>
Then setup an "onafterlogin" Auto-Action redirect (with related condition about desired user plan) to the above html page. Finally the other small "delayer" javascript, redirect user 1 second later for example to his CB profile. Using this method, the GA code is well fired, however it must be possible to fire the code without this external html page.
any clue ?