Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Thanks, edited my question.

I need a reliable way to capture a GA event whenever the GA tracking code fires for a particular page only. Doing so because we want to assign a dollar value to simply viewing a certain page (or type of page), and this can happen multiple times per visit, so a destination based goal isn't feasible

I tried using a window.onload javascript (also tried window.onbeforeunload) to trigger the event, but I can only get about 80% of the pageviews to become events (and only about 12% for our mobile website!). Not accurate enough yet for "prime time"

Thanks :)

share|improve this question

1 Answer 1

In your GA script you can place the event. Although I can't think of a single reason you would want to do this, that's your thing, not mine I suppose.

Just place your event in the same script tag right above the first line (usually var _gaq = _gaq || [];).

Also, PHP has nothing to do with JS as it is server-side, JS is client-side.

share|improve this answer
    
Thanks I'd be glad to give this solution a try and mark your answer as accepted; would you mind putting that code in context for me, i.e. making this line of code look more complete? This looks kind of sparse to my eyes –  Drewdavid Aug 8 '13 at 18:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.