Custom Value with Asynchronous tracking


#1

Ні.
I try to enable Custom Value on my site and I don’t receive any Custom Value :frowning:

Code example:
[i]

<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
(function(){
	var u=(("https:" == document.location.protocol) ? "https://piwik.xxx.xxx/" : "http://piwik.xxx.xxx/");
	_paq.push(['setSiteId', 6]);
	_paq.push(['setTrackerUrl', u+'piwik.php']);
	_paq.push(['trackPageView']);
	_paq.push(['enableLinkTracking']);
	var d=document,
    	g=d.createElement('script'),
   		s=d.getElementsByTagName('script')[0];
    	g.type='text/javascript';
    	g.defer=true;
    	g.async=true;
    	g.src=u+'piwik.js';
    	s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->


	<title>Test page</title>
</head>
<body>



<script type="text/javascript">  
	function CustomValue() { 
	_paq.push(['setCustomVariable','1','VisitorType','Member','page']);} 
</script> 		

<button name="test4" type="button"  onclick="CustomValue();">Custom1 Variable2</button>

</body>
[/i]

Please Tell me what am I doing wrong


(Matthieu Aubry) #2

Put the main Piwik code in teh bottom before /body and it should work better?


(vipsoft) #3

Basically, you have to set the custom variable before you call trackPageView.