Skip to content

Instantly share code, notes, and snippets.

@tordans
Created August 15, 2011 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tordans/1145854 to your computer and use it in GitHub Desktop.
Save tordans/1145854 to your computer and use it in GitHub Desktop.
Script to track secondary domain redirects.
<?php
// Usage:
// - Configure your secondary domain to open this file/folder.
// - The file will redirect to your primary domain with tracking prameters (Google Analytics used below)
// - Optional: Use those tracking parameters in your primary domain's index-file to set an additional tracking-snippet. See example for details. This step is necessary for stayscout since we use eTracker which does not support campaign-tracking by URL but only by calling a script after the page has been rendered.
// Example:
// http://staiscout.de -> redirects to https://stayscout.de/?utm_source=tippfehlerdomain&utm_medium=staiscout-de and adds this JS+jQuery-code at the end of the body-tag for etracker:
// <!-- Tippfehlerdomain-Tracking -->
// <script type='text/javascript'>
// $(function() { ET_Event.eventStart('Tippfehlerdomain', '', 'staiscout-de', ''); });
// </script>
header("Location: http://stayscout.de/?utm_source=tippfehlerdomain&utm_medium=" . str_replace(".", "-", $_SERVER["HTTP_HOST"]),TRUE,301);
// Help: 301 Moved Permanently - http://us3.php.net/manual/de/function.header.php#78470
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment