lesssugar
lesssugar

Reputation: 16181

Tracking clicks of guest users, with some decent kind of uniqueness

Please be advised, this is not a code-problem question.

I have a resource in my app that is available only for authenticated users. In case a guest user tries to access the resource by clicking on it - registration modal shows up.

Now, I'm building logic using jQuery and PHP in order to store those clicks of guests. However, I also would like to implement something, that will let me retrieve rough information on unique users among the ones who clicked.

The idea I have is this:

  1. When a specific page is loaded, set a JS cookie of "unique" value, like this: [random string of fixed size][timestamp]. The cookie would expire in a year from now. If the cookie already exists, don't do anything.
  2. When the guest clicks on the resource, make an Ajax call to store the click AND the cookie value.
  3. Later, to get "unique" clicks, make a SELECT that will GROUP BY the cookie value.

Unless the cookies are cleared or the custom cookie expiration date is exceeded, this should give me a way to determine unique clicks (users) among guests.

I'm interested, if anyone can provide me with a better way to achieve what I need.

Upvotes: 0

Views: 89

Answers (1)

Axel Amthor
Axel Amthor

Reputation: 11096

I wouldn't reinvent the wheel and use Google Analytics for this kind of task, since it's almost doing al the job and giving you nice graphics and statistics for free.

Upvotes: 1

Related Questions