Difference between revisions of "How do I redirect to preserve tracking tags?"

From Market Ruler Help
Jump to: navigation, search
(created)
(No difference)

Revision as of 14:33, 27 November 2012

Some sites do automatic redirection for a variety of reasons:

  • A/B Testing
  • URL changes
  • Ended Campaigns or Landing Pages updated

If your page redirects using JavaScript, you can still track on that page by using a bit of JavaScript for redirection:

<script type="text/javascript">

/* Edit this URL as needed */

var redirect_url = 'http://www.example.com/page/to/redirect.html?to=here';

/* Shouldn't need to edit below here */ var query_string = window.location.search, referrer = window.document.referrer; if (query_string) { redirect_url += (redirect_url.indexOf('?') >= 0 ? '&' : '?') + query_string.substr(1); } if (referrer) { redirect_url += (redirect_url.indexOf('?') >= 0 ? '&' : '?') + "crxref=" + escape(referrer); } window.location = redirect_url; </script>

The redirect code actually preserves all query string parameters, and also adds the page referrer to the URL so it can be recorded by ConversionRuler.