Drupal with Google Campaign codes

Tech Notes

In a previous article I've written on tracking visitors arriving at your site from print or other offline media. Short URLs or QRCodes are a good way to create shorter Google campaign-tagged links that are easier for your visitors to get your link and the rather long campaign code.

Another way to provide a tagged URL that doesn't take 15 minutes to type in to your phone is with the Redirect module for Drupal. It has the additional advantage of being able to control the campaign code and target URL after you go to print (most 3rd party URL shorteners don't allow you to change URLs after you create the link). And you also maintain your own branded domain name. 

  1. Use Google's URL builder to create a link to your target page. I've written a previous article on how to use it.
  2. Download and enable the Redirect module. Find the Redirect list page at admin/config/search/redirect (Redirect syncronises your Pathauto aliases so if you are using that you will see a lot of existing redirects).
  3. Add a new redirect (admin/config/search/redirect/add). From can be a short path (for example the name of your campaign) that you are not already using. In the To field paste in your campaign tagged URL to your target page. 301 Redirects are the ones to use in this case (301s mean permanently moved).
  4. Test your results. A good way to do this is using Google Analytics' Real Time results. You need the Traffic Sources tab. Visit your Redirect URL (the short one) and notice that you end up at your target page with the campaign query string. Notice in the real time results you'll see a row appear listing your source and medium you configured for your campaign.

You could still use a shortener to get an even tinier URL or a QRCode on top of this method. But you would still have the flexibility of changing the campaign and target later on.