Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

GA Custom Variable AdWords Tracking

By: adrianvender on Jan 24th, 2012  |  syntax: JavaScript  |  size: 0.58 KB  |  views: 293  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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>