A_Nix
A_Nix

Reputation: 1

deleteCustomVar not working

I am using google analytics and I have set 5 custom variables. I have tried to delete the custom variables using the following code.

$temp .= <<<_HTML
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-2']);
  _gaq.push(['_deleteCustomVar', 1]);
  _gaq.push(['_deleteCustomVar', 2]);
  _gaq.push(['_deleteCustomVar', 3]);
  _gaq.push(['_deleteCustomVar', 4]);
  _gaq.push(['_deleteCustomVar', 5]);
  _gaq.push(['_trackPageview']);

(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>
_HTML;
return $temp;

The custom variables still appear at this point. I am wondering if my syntax is wrong, or if I am missing something. Any help would be appreciated.

Upvotes: 0

Views: 262

Answers (1)

mike
mike

Reputation: 7177

Are you sure you're seeing the custom variables on tracking data after you updated your code, and not just on older data? _deleteCustomVar doesn't affect past data, it only removes the variable name from the analytics cookie.

Upvotes: 3

Related Questions