1

I have a page I'm working on that is just a redirect page to get some browser data before sending them off to an external site. It's a white HTML page with just the google analytics code and then it redirects to Kickstarter. My problem is I don't know when I can redirect them. I want to know when the data was sent to their servers so I can redirect them. I can see how to get callback data for custom tracking, but I want all the browser data.

I see this code here: https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#hitCallback

But that seems to just be custom page view sends. Is there anyway to just do a general onload event for google analytics?


UPDATE: Some people are finding my question hard to understand. I'll try to make this simpler although I figured this was almost as simple as I could make it.

I'm doing nothing custom with Google Analytics. I just want to know when, on any page that has google analytics tracking code (the stuff you copy and paste) has loaded and sent the data up to Google. So, in theory, like ga.onload(function () { ... }). Hope that helps?

Oscar Godson
  • 31,662
  • 41
  • 121
  • 201
  • I do not understand your last sentence. The hit callback is executed as soon as Google has sent data to the tracking server, which is what you want - so do your redirect in the callback function. – Eike Pierstorff Nov 27 '14 at 12:11
  • As it's currently written, it’s hard to tell exactly what you're asking. See the [How to Ask page](http://stackoverflow.com/help/how-to-ask) for help clarifying this question. – carlodurso Nov 28 '14 at 23:45
  • @EikePierstorff I've tried updating it. I'm not sure how else I can explain it other than the updated version – Oscar Godson Dec 02 '14 at 05:30
  • @carlodurso see comment above (I couldn't tag you in the same comment I guess?) – Oscar Godson Dec 02 '14 at 05:30

1 Answers1

0

Oscar,

What's difficult to picture in your question is the navigation flow and where to pinpoint the issue:

A page redirects to a page to get some browser data before sending them off to an external site.

Google recommends placing the tracking code on the redirecting page as well as on the landing page. This way, the redirecting page will capture the actual referrer information for your reports.

Fundamentally, whenever the user hits a page with the tracking script a request to google is sent notifying about the visit. However, some browsers may actually redirect before the JavaScript call from the code can be made.


Possible solutions:

  • Implement your own counter inside the redirect script, separated from GA
  • Implement an event before the redirect happens
  • Implement an event on the redirect page with the useBeacon parameter



References:

https://support.google.com/analytics/answer/1009614?hl=en

track a redirect page with google analytics

Community
  • 1
  • 1
carlodurso
  • 2,886
  • 4
  • 24
  • 37
  • Hmm, sorry I'm not explaining this better. I tried to make it as short as possible to make it clear, but, I'm not having problems with the redirect or tracking it manually or any of that. I know the user might go to the new page before it loads, thats exactly my question. How do I know when the call is made and the request is finished? – Oscar Godson Dec 02 '14 at 21:44
  • I'm currently doing a completely manual page view track the ga page view track and then redirecting in the callback. However, I'd rather _not_ do a manual page view track. Does that make anymore sense? Literally my question is: is there a google analytics onload event or callback – Oscar Godson Dec 02 '14 at 21:45
  • Maybe [hit Callback](https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#hitCallback) can help in your case. – carlodurso Dec 02 '14 at 21:52