Jump to content

Wuhtzu

Members
  • Posts

    702
  • Joined

  • Last visited

    Never

Everything posted by Wuhtzu

  1. What I needed I found documented here: http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html#PushingFunctions The function just has to be passed to _gaq.push() like a function and not a string: onbeforeunload="timeTracker._recordEndTime(); _gaq.push([function(){ eTr = _gat._getTrackerByName('eventTracker'); timeTracker._track(eTr, undefined, document.title);}]);"
  2. I guess you are right, that might prevent some of the string in string problems. I'll try that and get back to you
  3. Hi everyone I am playing around with Google Analytics asynchronous tracking code and facing a "problem" where I have to have strings within strings in java script called by event handlers such as onClick. This piece of java script needs to be called when the even handler onBeforeUnload fires: onbeforeunload="timeTracker._recordEndTime(); _gaq.push(['java script code']);" So _gaq.push(['java script code']) takes a string of java script code and enqueues it for execution. The piece of codes needing to be executed is this: function(){ eTr = _gat._getTrackerByName('eventTracker'); timeTracker._track(eTr, undefined, document.title);} As you can see the code above function(){} has a string in it. How should those two pieces of code be merged so that everything gets interpreted correct? onbeforeunload="timeTracker._recordEndTime(); _gaq.push(['function(){ eTr = _gat._getTrackerByName('eventTracker'); timeTracker._track(eTr, undefined, document.title);}']);" I cannot mix " and ' since the html tags use ". The above with 'code 'string' more code' does (obviously) not work and escaping the quotes \' does not work either. Any suggestions? Best regards Wuhtzu
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.