2

I have an application that navigates mostly with AJAX, and a section where a user can view information. I would like to track how long users are viewing different pieces of information. I want to assume that as long as they have the information loaded in the <div> they are "viewing" it. However when the user click on a link to "go to another section of the app" the <div> gets loaded with different content, the page doesn't actually redirect.

Does anyone have a solution for this, or at least some thoughts to help me see something I cannot see right now?

Thanks

digawp
  • 324
  • 2
  • 13
Dagron
  • 175
  • 2
  • 14

2 Answers2

1

Most analytics software will allow you track this. I have some experience with Google Analytics and it's something like:

ga.track("my-event", my_data);

Setting up a timer shouldn't be too hard. Put that code in the routine that handles content un/loading.

Halcyon
  • 57,230
  • 10
  • 89
  • 128
  • can you please explain the - the routine that handles content un/loading? do I need google analytics to do this? Or can I handle the events myself? – Dagron May 12 '15 at 16:21
  • I assume you have this routine already .. how else is content getting loading/unloaded when clicking a link? Also, what analytics software are you using? – Halcyon May 12 '15 at 16:23
  • I have Google Analytics, and I do have routing functionality setup - now that you say that I understand what you mean. I will test and report. – Dagron May 12 '15 at 16:25
0

You should call some function when you update your content.

Since there is no "onchange" event for divs, you'll have to call your function after the ajax process: See this answer for more info.

However, if your content doesn't change according to ajax calls, you should trigger some event when your div changes.

Hope I helped you: without any code fragment I can't do more!

Community
  • 1
  • 1
moonknight
  • 334
  • 1
  • 7