|
68 | 68 | return matches ? decodeURIComponent(matches[1]) : undefined; |
69 | 69 | }, |
70 | 70 |
|
71 | | - // Injects Google Analytics Script. |
| 71 | + /** |
| 72 | + * Injects Google Analytics Script. |
| 73 | + * |
| 74 | + * Removed in 2.9.7. Always returns false. |
| 75 | + */ |
72 | 76 | injectGAScript = function ( injectNow ) { |
73 | | - if ( true === injectNow ) { |
74 | | - // This injector script is for GA have made minor modifications to fix linting issue. |
75 | | - (function(i, s, o, g, r, a, m) { |
76 | | - i.GoogleAnalyticsObject = r; |
77 | | - i[r] = i[r] || function() { |
78 | | - (i[r].q = i[r].q || []).push(arguments); |
79 | | - }; i[r].l = 1 * new Date(); |
80 | | - a = s.createElement(o); |
81 | | - m = s.getElementsByTagName(o)[0]; |
82 | | - a.async = 1; |
83 | | - a.src = g; |
84 | | - m.parentNode.insertBefore(a, m); |
85 | | - })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'lpga'); |
86 | | - return window[window.GoogleAnalyticsObject || 'lpga']; |
87 | | - } |
88 | | - }, |
89 | | - |
90 | | - // Send event to LaterPay GA. |
91 | | - sendParentEvent = function( injectNow, eventlabel, eventAction, eventCategory, eventValue, eventInteraction ) { |
92 | | - var lpga = injectGAScript( injectNow ); |
93 | | - if (typeof lpga === 'function') { |
94 | | - lpga( 'create', lpCommonVar.lp_tracking_id, 'auto', 'lpParentTracker' ); |
95 | | - lpga('lpParentTracker.send', 'event', { |
96 | | - eventCategory : eventCategory, |
97 | | - eventAction : eventAction, |
98 | | - eventLabel : eventlabel, |
99 | | - eventValue : eventValue, |
100 | | - nonInteraction : eventInteraction, |
101 | | - }); |
102 | | - } |
103 | | - }, |
104 | | - |
105 | | - // Send event to User GA. |
106 | | - sendUserEvent = function( injectNow, eventlabel, eventAction, eventCategory, eventValue, eventInteraction ) { |
107 | | - var lpga = injectGAScript( injectNow ); |
108 | | - if (typeof lpga === 'function') { |
109 | | - lpga( 'create', lpCommonVar.lp_user_tracking_id, 'auto', 'lpUserTracker' ); |
110 | | - lpga( 'lpUserTracker.send', 'event', { |
111 | | - eventCategory : eventCategory, |
112 | | - eventAction : eventAction, |
113 | | - eventLabel : eventlabel, |
114 | | - eventValue : eventValue, |
115 | | - nonInteraction : eventInteraction, |
116 | | - }); |
117 | | - } |
| 77 | + return false; |
118 | 78 | }, |
119 | 79 |
|
120 | 80 | // Read Post Purchased Cookie. |
|
127 | 87 | } |
128 | 88 | }, |
129 | 89 |
|
130 | | - // Detect if GA is Enabled by MonsterInsights Plugin. |
131 | | - detectMonsterInsightsGA = function () { |
132 | | - if ( typeof window.mi_track_user === 'boolean' && true === window.mi_trac_user ) { |
133 | | - return window[window.GoogleAnalyticsObject || '__gaTracker']; |
134 | | - } |
135 | | - }, |
136 | | - |
137 | | - // Create a tracker and send event to GA. |
138 | | - createTrackerAndSendEvent = function ( gaTracker, trackingId, trackerName, eventAction, eventLabel, |
139 | | - eventCategory, eventValue, eventInteraction ) { |
140 | | - gaTracker( 'create', trackingId, 'auto', trackerName ); |
141 | | - gaTracker( trackerName + '.send', 'event', { |
142 | | - eventCategory : eventCategory, |
143 | | - eventAction : eventAction, |
144 | | - eventLabel : eventLabel, |
145 | | - eventValue : eventValue, |
146 | | - nonInteraction : eventInteraction, |
147 | | - }); |
148 | | - }, |
149 | | - |
150 | 90 | daysPassedSinceEvent = function( date1, date2 ) { |
151 | 91 |
|
152 | 92 | //Get 1 day in milliseconds |
|
361 | 301 |
|
362 | 302 | window.lpGlobal = { |
363 | 303 |
|
364 | | - // Send GA Event conditionally. |
| 304 | + /** |
| 305 | + * Send GA Event conditionally. |
| 306 | + * |
| 307 | + * Removed in 2.9.7, always returns false. |
| 308 | + */ |
365 | 309 | sendLPGAEvent: function ( eventAction, eventCategory, eventLabel, eventValue, eventInteraction ) { |
366 | | - |
367 | | - if ( 'undefined' === typeof eventInteraction ) { |
368 | | - eventInteraction = false; |
369 | | - } |
370 | | - |
371 | | - var sentUserEvent = false; |
372 | | - var __gaTracker = detectMonsterInsightsGA(); |
373 | | - var trackers = ''; |
374 | | - var userUAID = lpCommonVar.lp_user_tracking_id; |
375 | | - var lpUAID = lpCommonVar.lp_tracking_id; |
376 | | - |
377 | | - if( userUAID.length > 0 && lpUAID.length > 0 ) { |
378 | | - |
379 | | - if (typeof __gaTracker === 'function' ) { |
380 | | - trackers = __gaTracker.getAll(); |
381 | | - trackers.forEach(function(tracker) { |
382 | | - if ( userUAID === tracker.get('trackingId') ) { |
383 | | - sentUserEvent = true; |
384 | | - var trackerName = tracker.get('name'); |
385 | | - __gaTracker( trackerName + '.send', 'event', { |
386 | | - eventCategory : eventCategory, |
387 | | - eventAction : eventAction, |
388 | | - eventLabel : eventLabel, |
389 | | - eventValue : eventValue, |
390 | | - nonInteraction : eventInteraction, |
391 | | - }); |
392 | | - } |
393 | | - }); |
394 | | - |
395 | | - if ( true === sentUserEvent ) { |
396 | | - createTrackerAndSendEvent( lpUAID, 'lpParentTracker', eventAction, eventLabel, |
397 | | - eventCategory, eventValue, eventInteraction ); |
398 | | - } else { |
399 | | - createTrackerAndSendEvent( __gaTracker, lpUAID, 'lpParentTracker', eventAction, |
400 | | - eventLabel, eventCategory, eventValue, eventInteraction ); |
401 | | - createTrackerAndSendEvent( __gaTracker, userUAID, 'lpUserTracker', eventAction, |
402 | | - eventLabel, eventCategory, eventValue, eventInteraction ); |
403 | | - } |
404 | | - } else { |
405 | | - sendParentEvent( true, eventLabel, eventAction, eventCategory, eventValue, eventInteraction ); |
406 | | - sendUserEvent( true, eventLabel, eventAction, eventCategory, eventValue, eventInteraction ); |
407 | | - } |
408 | | - } else if( userUAID.length > 0 && lpUAID.length === 0 ) { |
409 | | - if (typeof __gaTracker === 'function') { |
410 | | - trackers = __gaTracker.getAll(); |
411 | | - trackers.forEach(function (tracker) { |
412 | | - if (userUAID === tracker.get('trackingId')) { |
413 | | - sentUserEvent = true; |
414 | | - var trackerName = tracker.get('name'); |
415 | | - __gaTracker(trackerName + '.send', 'event', { |
416 | | - eventCategory : eventCategory, |
417 | | - eventAction : eventAction, |
418 | | - eventLabel : eventLabel, |
419 | | - eventValue : eventValue, |
420 | | - nonInteraction : eventInteraction, |
421 | | - }); |
422 | | - } |
423 | | - }); |
424 | | - |
425 | | - if (true !== sentUserEvent) { |
426 | | - sendUserEvent(true, eventLabel, eventAction, eventCategory, eventValue,eventInteraction); |
427 | | - } |
428 | | - } else { |
429 | | - sendUserEvent(true, eventLabel, eventAction, eventCategory, eventValue,eventInteraction); |
430 | | - } |
431 | | - } else if( userUAID.length === 0 && lpUAID.length > 0 ) { |
432 | | - if (typeof __gaTracker === 'function' ) { |
433 | | - createTrackerAndSendEvent( __gaTracker, lpUAID, 'lpParentTracker', eventAction, eventLabel, |
434 | | - eventCategory, eventValue, eventInteraction ); |
435 | | - } else{ |
436 | | - sendParentEvent( true, eventLabel, eventAction, eventCategory, eventValue, eventInteraction ); |
437 | | - } |
438 | | - } |
| 310 | + return false; |
439 | 311 | } |
440 | 312 | }; |
441 | 313 |
|
|
0 commit comments