JavaScript Tracker: externalizing parameters


#1

UPDATE: please disregard, I fixed the problem.


I’m using a JavaScript Tracker. What I wish to do is abstract out some of the parameters to a separate JavaScript object – what my client is calling the Data Layer.

Here is the existing code:


   
   

I would like to abstract out these parameters:

			'd1epsz32winqbo.cloudfront.net', 
		   { // Initialise a tracker
			   appId: 'TEST_Star_Tribune_1226pm', // Application ID. Make sure you use the same value across all the tags you fire on your trial
			   platform: 'web'
		   }

I was thinking about doing something like the code below, with a global “window” variable named “stdl” (for Star Tribune Data Layer). –

window.stdl = { // Initialise a tracker
           appId: 'KGJ_Aug_26_1210', // Application ID. Make sure you use the same value across all the tags you fire on your trial
           platform: 'web'
       };

Then the Snowplow JS would refer to “window.stdl” where it consumes the parameters.

BUT – this does not work, apparently due to scoping issues.

Please advise, thanks.

Karl