Skip to content

Instantly share code, notes, and snippets.

@spkellydev
Created November 15, 2017 16:09
Show Gist options
  • Save spkellydev/ab4745b193f96754235b40ec5bd66ffb to your computer and use it in GitHub Desktop.
Save spkellydev/ab4745b193f96754235b40ec5bd66ffb to your computer and use it in GitHub Desktop.
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