|
20 | 20 | <!-- Snowplow starts plowing --> |
21 | 21 | <script type="text/javascript"> |
22 | 22 |
|
| 23 | + window.scriptManager = (function() { |
| 24 | + |
| 25 | + scriptQueue = []; |
| 26 | + |
| 27 | + function enqueueScript(src, namespace) { |
| 28 | + scriptQueue.push([src, namespace]); |
| 29 | + if (scriptQueue.length === 1) { |
| 30 | + dealWithNextScript(); |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + function dealWithNextScript() { |
| 35 | + if (scriptQueue.length > 0) { |
| 36 | + var newScript = document.createElement('script'); |
| 37 | + var initialScript = document.getElementsByTagName('script')[0]; |
| 38 | + newScript.async = 1; |
| 39 | + newScript.onload = function() { |
| 40 | + scriptQueue.shift(); |
| 41 | + dealWithNextScript(); |
| 42 | + } |
| 43 | + newScript.onerror = function() { |
| 44 | + scriptQueue.shift(); |
| 45 | + dealWithNextScript(); |
| 46 | + } |
| 47 | + newScript.src = scriptQueue[0][0]; |
| 48 | + initialScript.parentNode.insertBefore(newScript,initialScript); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + return { |
| 53 | + enqueueScript: enqueueScript |
| 54 | + } |
| 55 | + |
| 56 | + }()); |
| 57 | + |
23 | 58 | ;(function(p,l,o,w,i,n,g) { |
24 | 59 | p['GlobalSnowplowNamespace'] = p['GlobalSnowplowNamespace']||[]; |
25 | 60 | p['GlobalSnowplowNamespace'].push(i); |
26 | 61 | p[i] = p[i] || function() { |
27 | 62 | (p[i].q = p[i].q||[]).push(arguments); |
28 | 63 | }; |
29 | 64 | p[i].q = p[i].q || []; |
30 | | - n = l.createElement(o); |
| 65 | + scriptManager.enqueueScript(w, i); |
| 66 | + /*n = l.createElement(o); |
31 | 67 | g = l.getElementsByTagName(o)[0]; |
32 | 68 | n.async = 1; |
33 | 69 | n.src = w; |
34 | | - g.parentNode.insertBefore(n,g); |
| 70 | + g.parentNode.insertBefore(n,g);*/ |
35 | 71 | }(window, document, 'script', '../../dist/snowplow.js', 'new_name_here')); |
36 | 72 |
|
37 | 73 | window.new_name_here('newTracker', 'primaryTrackerNamespace', 'd3rkrsqld9gmqf.cloudfront.net'); |
|
66 | 102 | <script type="text/javascript"> |
67 | 103 |
|
68 | 104 | function playMix() { |
69 | | - alert("Playing a DJ mix"); console.log(window.new_name_here.q) |
| 105 | + alert("Playing a DJ mix"); |
70 | 106 | window.new_name_here('trackStructEvent', 'Mixes', 'Play', 'MRC/fabric-0503-mix', '', '0.0'); |
71 | 107 | } |
72 | 108 | function addProduct() { |
|
0 commit comments