Skip to content

Instantly share code, notes, and snippets.

@underdown
Created August 21, 2013 16:38
Show Gist options
  • Select an option

  • Save underdown/6296854 to your computer and use it in GitHub Desktop.

Select an option

Save underdown/6296854 to your computer and use it in GitHub Desktop.
include distinct analytics tags by referrer
$allowed_host = 'd3cream.com';
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if(substr($host, 0 - strlen($allowed_host)) == $allowed_host) {
include('analytics-d3.php');
} else {
include('analytics.php');
}
@underdown

Copy link
Copy Markdown
Author

this is pretty dangerous unless you control the referrer you are checking. Referrer sniffing is fraught with peril. (https etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment