Tuesday, April 3, 2012

Tracking Ajax clicks through Google Analytics or other analytics tool

If you would like to track Ajax clicks do the following:

If you use Google analytics

Implement the solution in the following link

http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55521

Using other analytics tool

1- Create an IFRAME and make it invisible ( do NOT use display:none )
2- Create an empty page but add your analytics code inside
3- On each ajax click, change the source of the IFRAME to be the page you have just created

Now on each click you will find the page visited in your analytics tool, also if you would like to differentiate between users you should add "?user_id=IP" or  "?user_id=SESSION_ID" to the page path

<iframe id='ID' src='' style="position:absolute;bottom:0px;left:0px;visibility:hidden;width:0px;height:0px"></iframe>



$("#ID").attr("src","/YOURPAGE.php?user_id=200.123.139.116");


1 comment:

  1. Hi ,
    I an having problem in my android apps.

    Error generating final archive: java.io.FileNotFoundException: C:\Users\mvarshney\workspace\Myfirstapp\bin\resources.ap_ does not exist


    How would i Solve it???
    Regards-
    Mayank

    ReplyDelete