This post shows how to set up 301 redirects to track vanity URLs in analytics tools like Google Analytics and IBM Digital Analytics (Coremetrics). This will ensure marketing query strings are appended to the destination page, so that marketing sources can be correctly tracked.
Vanity URLs for Marketing
Adding tracking parameters to URLs is an essential part of a marketing campaign strategy, as these tracking parameters enable you to see how your marketing efforts are performing. However, sometimes it’s not optimal to hand out a long link filled with tracking parameters, for example on TV or through direct mail. One solution is to shorten your URL using a service like bit.ly, but that may seem unprofessional, harder to remember, or just not as nice as using your own domain name. So, in those cases, the best solution is to hand out a “vanity” URL that is easy to remember and share.
An example of a short and memorable vanity URL would be www.site.com/promo.
Vanity URL Redirects
Campaign tracking involves adding query strings (aka marketing tags) to the end of marketing links. Vanity URLs don’t contain any query strings, so instead they need to redirect to a full URL containing tracking parameters. Example:
The example above contains tracking parameters for Google Analytics, but you could just as easily apply cm_mmc parameters for Coremetrics, or your custom tracking parameters for Omniture.
Redirect Technical Implementation
Vanity URL redirects should be implemented as a 301 redirect. There are many methods for implementing redirects, and it will depend on your setup. However if you’re doing this yourself using a CMS like WordPress, these are the steps to set up a redirect for vanity URLs:
- Open and edit your .htaccess file (you can just create a new text file named .htaccess if there isn’t one there already).❓ The .htaccess file is a text file you can most easily access by a plugin (e.g. Yoast’s popular WordPress SEO plugin). Alternately you can access it via FTP or through the File Manager in cPanel. It’s usually located in the root directory and hidden by default, so you might need to edit the Settings and check a box called Show Hidden Files.
- Create a backup copy of the existing .htaccess file. Don’t skip this part – it’s very easy to break your site if you make a mistake in your .htaccess file.
- Add the following text anywhere in the .htaccess file:
[GA example]===============OR====================1Redirect 301 /promo http://www.site.com/?utm_source=promo&utm_medium=redirect&utm_campaign=Feb_promo
[IBM Analytics example]1Redirect 301 /promo http://www.site.com/?cm_mmc=promo-_-redirect-_-Feb_promo-_-XYZ
Substitute in your page names and desired tracking parameters. Note that you don’t include the hostname on the first part, but you do on the second.
- In the above example, /promo refers to the vanity page path you’re redirecting from, and http://www.site.com/ refers to the page you’re redirecting to. You can redirect to any page on your site; if you wanted to redirect to a page other than a homepage, for example to ‘/newpage’, you’d implement the redirect as follows:1Redirect 301 /promo http://www.site.com/newpage?utm_source=promo&utm_medium=redirect&utm_campaign=Feb_promo
Following the above steps will let you distribute a simple vanity URL that redirects to a fully tagged destination URL for analytics tracking.