开发者

Creating unique link for each user

I have uploaded a video to my site and there are 5 users(user accounts). How can I create a unique link,to that video, for each user. My ultimate goal is to monitor/keep track how many times each user clicked that link. I am using php 开发者_如何学Goto develop my site.

Edited:

I am sending the link to users via email and I want to track the clicks even if the user is not logged in


The easy way is to take some unique bit of data, like the user id or name, and tack it onto a request URL as a parameter. If you're linking them to the video page...

<a href="/videopage.html?userid=<?php echo $user['id']; ?>">Video page</a>

Then you can look at server logs, Google Analytics, etc, and track that unique parameter.


If your users are logged in, why aren't you using session id to detect which user clicked the link?


If your website has a database you could track it there. You'd have a table that stores some identifier for the object being clicked (a URL, an ID of the video, ...) and the user ID. Then you could have a separate column for click-count, or store each click as a separate record with a timestamp and then count the number of records for a user.


I'm assuming your using sessions. if you're also using an analytics app like google analytics is should be as easy as appending their username to the link by checking to see if a user is logged in and setting their username in a session var and then you could just do this

<a href="videolink.php?user=<?php echo $_SESSION['userName'];?>">link</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜