Thanks, this sounds like the solution I am after. I am just having problems with implementing it. I don't use a framework so tried the swfobject.addLoadEvent method you suggested. Now I get a white page and the status bars says: "Read: www.google-analytics.com" and just hangs there There must be some problem with moving the code up here.
In my <head> I have the following code: http://pastebin.com/m2b031216 Can you see if there's obviously anything wrong with that? Thanks for your help :) (the function does get called and if i take out the GA bit the swf does display) On Jan 27, 9:09 am, Philip Hutchison <[email protected]> wrote: > the biggest 'gotcha' with placing the google code at the end of the <body> > element is that the google code gets executed before the page's > domready/onload events are triggered. > > this means if you're trying to display a SWF as quickly as possible, the > swfobject.embedSWF will not be invoked until AFTER google's code has loaded > and executed. your SWF's load time is therefore at the mercy of google's > servers. your alternate content will display until google's code is done > executing and swfobject is invoked via its domready/onload methods. > > if you want to avoid having to wait for google's code to execute first, you > can wrap it in a domready event. if you're using a javascript framework > such as jQuery, MooTools or dojo, you can usually just write something like > > window.addEvent("domready", function (){ > //paste google analytics code here > > }); > > if you don't use a framework, SWFObject has a built-in addEvent method you > can use. it's called > addLoadEvent(fn)http://code.google.com/p/swfobject/wiki/api > > You can use it like this: > > swfobject.addLoadEvent(function (){ > //paste google analytics code here > > }); > > You can find plenty of examples of people hotrodding the analytics code to > work in an domready/onload event, just do a google search. > > good luck > - philip > > On Mon, Jan 26, 2009 at 4:43 AM, Getify Solutions, Inc. > <[email protected]>wrote: > > > > > You know, I'll admit, I've had "issues" with GA code as well. Their > > documentation says to put it at the top of the page, but for page loading > > reasons, I did exactly as Aran suggests. And everything seems to work fine. > > > Well, most everything. Actually, there are a couple of nagging things that > > don't seem to work correctly, and I'm not sure if it's because of my > > placement of GA.js or if it's just bugs with GA or problems with how I set > > it up. > > > But anyway, even those nagging problems with GA are non-critical... all the > > main stuff I need works just fine as Aran suggests. But yeah, this is a > > confusing topic to get definitive answers on. Ask 10 people and you'll > > likely get 10 different opinions. > > > --Kyle > > > -------------------------------------------------- > > From: "Aran Rhee" <[email protected]> > > Sent: Monday, January 26, 2009 2:59 AM > > To: <[email protected]> > > Subject: RE: Added Google Analytics, alternative content flashes on screen > > > > Where is you GA code? > > > > The proper place to put all GA includes and code execution is at the very > > > bottom of the page just before the </body> tag. This way all other code o > > > the page needed for rendering / display can execute without having to > > wait > > > for the response back from the Google servers. > > > > Just keep in mind that HTML renders in order as it is loaded... > > > > Cheers, > > > Aran > > > > -----Original Message----- > > > From: [email protected] [mailto:[email protected]] On > > > Behalf Of saltedherring > > > Sent: Monday, 26 January 2009 12:17 PM > > > To: SWFObject > > > Subject: Added Google Analytics, alternative content flashes on screen > > > > Hi, > > > > I have SWFObject on one of our sites and since adding Google Analytics > > > JavaScript code to the page there's now a delay and the alternative no- > > > flash content shows on screen for a split second (maybe longer on > > > slower machines). Is there some way around this to keep the > > > alternative stuff hidden until the page is processed or some other > > > approach maybe? It must be a common problem? > > > > Any help appreciated, thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SWFObject" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/swfobject?hl=en -~----------~----~----~----~------~----~------~--~---
