Advertisement
adrianvender

GA Custom Variable AdWords Tracking

Jan 24th, 2012
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement