Skip to content

Url redirection and tracking using Google Analytics and Events tracking

Notifications You must be signed in to change notification settings

skarfr/track-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
skar
Mar 26, 2016
3fb6183 · Mar 26, 2016

History

8 Commits
Jan 28, 2016
Mar 26, 2016
Jan 29, 2016
Jan 29, 2016

Repository files navigation

Track & Redirect

This php script allows you to create specific URLs on your domain and to redirect them to their final destination. Before doing the redirection, this script will record visitors data using your own Google Analytics tracking system. It is basically the same principle as url shorteners except that you own the URL, and traffic information are linked to your Analytics account only.

Examples

  • John Doe wants to add on his linkedIn profile, a link to his pdf resume. Using this script, he will be able to redirect an url such as http://johndomain.doe/resume to the exact pdf location, and track all visits on his Google Analytics account.
  • I want to share my gitHub address on my blog. Using this script, I am able to redirect an url such as http://r.skar.fr/github to my real gitHub address, and track all visits on Google Analytics.

Requirements

How does it work ?

  • To create URLs on your domain and link them to "redirect.php", you must edit the file ".htaccess". If your URL is http://johndomain.doe/lolilol, then you must add "|lolilol" at the "RewriteRule" line, within existing parenthesis. I provided few examples in the file.
  • To setup your URL redirection, you must edit the file "redirect.php". All you have to do is edit/add a "case" within the "switch". I provided few examples in the file.
  • To enable Google Analytics tracking, you must replace the tracking code "UA-xxxxxxxx-1" with your own. This code is provided by Google Analytics itself.
  • While waiting for the redirection, the script will display a spinning loading wheel. This javascript comes from https://fgnass.github.io/spin.js/. Thanks.
  • This script use the Event Tracking system from Google Analytics. More info: https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Demo

If you visit the page http://r.skar.fr/github, you will be redirected to this github profile, and i should have a record of your visit in my Google Analytics

About

Url redirection and tracking using Google Analytics and Events tracking

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published