I was recently involved with a project that required tracking links from a Flash widget marketing campaign. The problem is, that Flash player does not send the referer in the header or allow the referer to be set programatically. So the solution is to set up a campaign that includes the referer as a GET string in the url. So, how do you get the domain name of the page that the Flash is embedded on? Well a good way is to use the ExternalInterface class. Like this:
referer = ExternalInterface.call('eval', 'window.location.hostname');
Then you just concat the referer var onto the end of your URLrequests. Simple right? Not quite. See, the client was encouraging their associates to put the widget onto social networking sites and personal blogs. Well apparently many of these sites strip out the allowScriptAccess=’always’ param of the embed/object tags. So Flash Player would pop up a screen that says:
ActionScript Security Error 2060: Security sandbox violation: ExternalInterface caller http://www.whateverdomain.com/whatever.swf
cannot access
http://www.whateverotherdomain.com/
So, what’s the fix?