Created
October 9, 2012 17:16
-
-
Save underdown/3860141 to your computer and use it in GitHub Desktop.
Adwords - Simple split testing - redirect keeping auto-tagging in place for Analytics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* bypass special offers for past visitors | |
| must ad ?remark=x to ads' destination url */ | |
| if($_GET["remark"]) { | |
| }else{ | |
| /* check to see if adwords sent visit */ | |
| if($_GET["gclid"]) { | |
| $source= $_GET["utm_source"]; | |
| $term= $_GET["utm_term"]; | |
| $medium= $_GET["utm_medium"]; | |
| $campaign=$_GET["utm_campaign"]; | |
| /* forward visitors to one of three variants while preserving adwords auto-tagging tags */ | |
| switch(rand(1,3)) { | |
| case 1: header('location: /index.php?utm_source='.$source.'&utm_medium='.$medium.'&utm_term='.$term.'&utm_campaign='.$campaign.'');break; | |
| case 2: header('location: /a/index.php?utm_source='.$source.'&utm_medium='.$medium.'&utm_term='.$term.'&utm_campaign='.$campaign.'');break; | |
| case 3: header('location: /b/index.php?utm_source='.$source.'&utm_medium='.$medium.'&utm_term='.$term.'&utm_campaign='.$campaign.'');break; | |
| } | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment