SHARE
TWEET

GA Custom Variable AdWords Tracking

adrianvender Jan 24th, 2012 313 Never
  1. <script type='text/javascript'>
  2. //Check if supplied parameter exists in query string
  3. function gup( name )
  4. {
  5.   name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  6.   var regexS = "[\\?&]"+name+"=([^&#]*)";
  7.   var regex = new RegExp( regexS );
  8.   var results = regex.exec( window.location.href );
  9.   if( results == null )
  10.     return "";
  11.   else
  12.     return results[1];
  13. }
  14.  
  15.  
  16. if(gup('gclid')!="" && gup('gaw_campaign')!="" && gup('gaw_term')!="") {
  17.         _gaq.push(['_setCustomVar',1,'GAWCampaign',gaw_campaign,1]);
  18.         _gaq.push(['_setCustomVar',2,'GAWTerm',gaw_term,1]);
  19. }
  20. </script>
RAW Paste Data
Top