-
-
Save delineas/f7ac23a08dfcf02eb35cd879cc7fbf44 to your computer and use it in GitHub Desktop.
Simple Event Tracking with Measurement Protocol Using cURL and PHP (plus redirect)
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
<? | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_RETURNTRANSFER => 1, | |
CURLOPT_URL => 'http://www.google-analytics.com/collect?v=1&tid=[UA-XXXXXXXXX-1]&cid=[RANDOM_INTEGER_OR_GUID]&t=event&ec=[EVENT_CATEGORY]&ea=[EVENT_ACTION]&el=[EVENT_LABEL]', | |
CURLOPT_USERAGENT => 'Vanity-URL-Tracker', | |
)); | |
$resp = curl_exec($curl); | |
curl_close($curl); | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: http://www.reddit.com/"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment