Search code examples
javascripthtmlanalytics

Need to understand how tracking codes may be working in web content


I was recently approached by a web partner and they asked me to add their 'tracking code' to my site as shown below. The data and address would be different, but the structure is the same as below. Currently they load our site in an IFrame and what I can't understand is...

How could the script portion provide any value to them? Can a parent page read JavaScript state of something in a hosted IFrame? Google uses a similar pattern but they set the src which has Script that is executed when the page loads and could read the state.

Can anyone explain how this might be working or is this just useless page spam?

<img src="https://www.APartnerCompany.foo/thing.img?arg=value" />

<script type="text/javascript">
//<![CDATA[ 
var Foo = {}; 
Foo.Tracking = {}; 
Foo.Tracking.Sale = {}; 
Foo.Tracking.Sale.amount = '100.00'; 
//]]> 
</script>

Solution

  • An inline script can also read values from the page it is contained in. To post them back to their own server, they seem to use the src attribute of that affiliate image. However, the pieces you provided are harmless (the code does nothing than constructing an object) and requests only a non-executable from https://www.APartnerCompany.foo/thing.img?arg=value (beeing logged at theirs).