Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firing off JavaScript via getURL for analytics data

Status
Not open for further replies.

Rieekan

Programmer
Apr 2, 2001
737
US
I have a small Flash application that is displaying a varying number of ads in a carousel-type fashion which our users can click on any ad to go to a given product page. Our Analytics department has requested that we track information on what the user is doing while on the page with the carousel including:

[ul]
[li]each ad viewed[/li]
[li]skipping ads by clicking on a specific number or a FF/RW button[/li]
[li]pausing the current ad[/li]
[li]starting the carousel feature back up (hitting play)[/li]
[li]clicking on an ad to visit a given product[/li]
[/ul]

All analytics data is sent to the specific servers by a JavaScript function provided by the Analytics vendor.

Each of the above listed features work just fine with the exception of when a user clicks on an ad to go to the product page. I have a feeling it's due to the fact that I am calling the getURL function twice in very rapid succession and the browser hasn't had the opportunity to complete running the JavaScript code before the request changes.

Does anyone know of a possible alternative or workaround to allow the window enough time to get the JavaScript function to complete before moving on and sending the user to the next page?

Any and all help is much appreciated,

- George
 
One possible solution is to use LoadVars to send a data to the server and only issue getURL() on receiving the response from it.
The issues for this are:
1. You have to change your server side script so that it returns something.
2. Depending on the connection etc, the user may have to wait some time before it gets to the new web site.

The other possibility is to use ExternalInterface (or Flash Javascript Method) to receive a call back from Javascript function. You will issue the getURL() only after you receive the call back from the first logging call. This technique may have the same issue of the user having to wait but the waiting time should be far shorter compared to the first solution. Also you need to test this first as I'm not 100% sure if this actually works...

Another possibility is just open a new browser window using "_blank". You need to test this first as well.

Kenneth Kawamoto
 
Thanks, I'll look into the LoadVars option as it seems to be the more appropriate since we don't own the codebase for the analytics software, but it does return a GIF image.

Thanks!

- George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top