Created
November 15, 2017 16:09
-
-
Save spkellydev/ab4745b193f96754235b40ec5bd66ffb to your computer and use it in GitHub Desktop.
This file contains 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
function other_referrers($m) { | |
$s = ['twitter.com', 'instagram.com', 'tumblr.com', 'pinterest.com', 'youtube.com', 'linkedin.com']; | |
foreach ($s as $source) | |
{ | |
if ($m === $source ) { | |
return $source; | |
} | |
} | |
} | |
function parse_referrer($referrer) { | |
$domain = parse_url($referrer); | |
//strip www off the URL | |
$url = preg_replace('#^www\.(.+\.)#i', '$1', $domain['host']); | |
//set match to url | |
$m = $url; | |
switch ($m): | |
case 'www.google.com': | |
return '60647'; //google adwords | |
break; | |
case 'www.facebook.com': | |
return '8889'; //facebook | |
break; | |
case other_referrers($m): | |
return ''; //no code for other social | |
break; | |
case 'themaxchallenge.com': | |
return '8891'; //website | |
break; | |
default: | |
return '60678'; //organic | |
endswitch; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment