Mobile app version of vmapp.org
Login or Join
Berryessa370

: I would probably write the code myself to track them. Although perhaps it would be easier trying to hook it into analytics. I'm not sure how to do that. To do the re-direct you would want

@Berryessa370

I would probably write the code myself to track them. Although perhaps it would be easier trying to hook it into analytics. I'm not sure how to do that.

To do the re-direct you would want to use .htaccess (providing you're using Apache server)
The .htacess file might look something like this:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([A-Z0-9]{5})$ track.php?id= [L]


The RewriteRule there will match someone going to example.com/HJK7D Basically example.com/ and any combination of 5 capital letters and or numbers. This will get re-written and the server will actually pull up track.php?id=HJK7D (in this case)

So drop that .htaccess into the main root directory of your website. Then create a file called track.php which might look something like this:

<?php
if(isset($_GET['id'] && strlen($_GET['id'])==5){
setcookie("id", $_GET['id'], time()+1209600); // expires in 2 weeks
}

header("HTTP/1.1 301 Moved Permanently");
header("Location: www.example.com/ );
?>


Then use the cookie $_COOKIE['id'] to track your visitor through your site.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Berryessa370

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme