From 1ed833e31c66272321d8cf3dc74c0abbab926301 Mon Sep 17 00:00:00 2001 From: cooperreid-optimizely Date: Wed, 6 Mar 2019 12:03:14 -0500 Subject: [PATCH 1/8] adobe_alignment branch --- Integrations/Analytics/Adobe Analytics/Alignment/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Integrations/Analytics/Adobe Analytics/Alignment/README.md diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md new file mode 100644 index 0000000..e69de29 From 9f2808d4247d734faed3d3612efc375889195d33 Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:13:10 -0500 Subject: [PATCH 2/8] Update README.md --- .../Analytics/Adobe Analytics/Alignment/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index e69de29..79f73a2 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -0,0 +1,14 @@ +# Aligning Adobe Analytics with Optimizely Results +For organizations where alignment is critical, there are a few technical considerations and adjustments to make in order to best align to metrics in the two systems. + +Misalignment can always be traced back to _when_ the two client tools are dispatching the impressions/conversions back to their respective servers. + +This challenge can be solved by aligning the two event calls as closely as possible. + +Optimizely offers the [hold/send API](https://help.optimizely.com/Set_Up_Optimizely/Control_the_timing_of_Optimizely_X_Web_Event_dispatch_with_holdEvents_and_sendEvents) for managing this. + +## Two scenarios + +### Adobe Loaded Ahead of Optimizely Snippet + +### Adobe not guaranteed to load ahead of Optimizely Snippet From dbbf51a864b65cc7bdd0feb02b7ecec22194b453 Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:34:07 -0500 Subject: [PATCH 3/8] Update README.md --- .../Adobe Analytics/Alignment/README.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index 79f73a2..8107dc4 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -11,4 +11,51 @@ Optimizely offers the [hold/send API](https://help.optimizely.com/Set_Up_Optimiz ### Adobe Loaded Ahead of Optimizely Snippet +Since Adobe is loaded first, we know the `s` variable is already defined by the time Optimizely Project JavaScript runs. We don't have to await it being defined. Hold events at the top of Project JS, register an Adobe pre-track handler that calls `sendEvents`. + +```javascript +window.optimizely = window.optimizely || []; +window.optimizely.push({type: "holdEvents"}); + +s.registerPreTrackCallback(function() { + // right before Adobe call + window.optimizely.push({type: "sendEvents"}); +}); +``` + ### Adobe not guaranteed to load ahead of Optimizely Snippet + +We need to wait for the `s` variable to be defined in order to register our pre-track handler. We can wrap our `registerPreTrackCallback` invocation with `waitUntil`, in order to guarantee that it can be called on the `s` variable. + +```javascript +window.optimizely = window.optimizely || []; +window.optimizely.push({type: "holdEvents"}); + +var waitFor = function(v, cb) { + var POLL, + WAIT_TIMEOUT = 2000, + POLL_INTERVAL_MS = 50; + + if(typeof v !== 'undefined') { + cb(v); + return; + } + POLL = setInterval(function() { + if(typeof v !== 'undefined') { + cb(v); + clearInterval(POLL) + } + }, POLL_INTERVAL_MS); + setTimeout(function() { + clearInterval(POLL) + }, WAIT_TIMEOUT); +} + +waitFor(window.s, function(sVariable) { + sVariable.registerPreTrackCallback(function() { + // right before Adobe call + window.optimizely.push({type: "sendEvents"}); + }); +}); +``` + From 69d20eece7de16de2c52d4e7038a4bb5f73c7080 Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:39:44 -0500 Subject: [PATCH 4/8] Update README.md --- .../Analytics/Adobe Analytics/Alignment/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index 8107dc4..6b5a2eb 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -31,11 +31,10 @@ We need to wait for the `s` variable to be defined in order to register our pre- window.optimizely = window.optimizely || []; window.optimizely.push({type: "holdEvents"}); -var waitFor = function(v, cb) { +var waitFor = function(v, cb, expiredCb) { var POLL, WAIT_TIMEOUT = 2000, POLL_INTERVAL_MS = 50; - if(typeof v !== 'undefined') { cb(v); return; @@ -47,7 +46,8 @@ var waitFor = function(v, cb) { } }, POLL_INTERVAL_MS); setTimeout(function() { - clearInterval(POLL) + clearInterval(POLL); + typeof expiredCb !== 'undefined' ? expiredCb() : null; }, WAIT_TIMEOUT); } @@ -56,6 +56,9 @@ waitFor(window.s, function(sVariable) { // right before Adobe call window.optimizely.push({type: "sendEvents"}); }); +}, function() { + // Adobe s variable polling expired, release events + window.optimizely.push({type: "sendEvents"}); }); ``` From ba722039a35d42b450020cab38c22ee3c65dec1c Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:48:26 -0500 Subject: [PATCH 5/8] Update README.md --- .../Adobe Analytics/Alignment/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index 6b5a2eb..b6efec2 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -25,6 +25,22 @@ s.registerPreTrackCallback(function() { ### Adobe not guaranteed to load ahead of Optimizely Snippet +Add the `holdEvents` call to the top of Project JavaScript + +```javascript +window.optimizely = window.optimizely || []; +window.optimizely.push({type: "holdEvents"}); +``` + +Add this JavaScript code to your Adobe Analytics `s_code.js` file in the *plug-ins* section (or directly on your page after the s_code.js loads, but before the Adobe Analytics s.t(); call is made) + +```javascript + window.optimizely = window.optimizely || []; + window.optimizely.push({type: "sendEvents"}); +``` + +### Adobe not guaranteed to load ahead of Optimizely Snippet (polling, not recommended) + We need to wait for the `s` variable to be defined in order to register our pre-track handler. We can wrap our `registerPreTrackCallback` invocation with `waitUntil`, in order to guarantee that it can be called on the `s` variable. ```javascript From 26623b487e6fca91fdb4b566e7dccaf6d6755d37 Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:50:52 -0500 Subject: [PATCH 6/8] Update README.md --- Integrations/Analytics/Adobe Analytics/Alignment/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index b6efec2..0b9c467 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -25,6 +25,8 @@ s.registerPreTrackCallback(function() { ### Adobe not guaranteed to load ahead of Optimizely Snippet +##### Recommended + Add the `holdEvents` call to the top of Project JavaScript ```javascript @@ -39,7 +41,8 @@ Add this JavaScript code to your Adobe Analytics `s_code.js` file in the *plug-i window.optimizely.push({type: "sendEvents"}); ``` -### Adobe not guaranteed to load ahead of Optimizely Snippet (polling, not recommended) +##### Not recommended +Uses `setInterval` polling We need to wait for the `s` variable to be defined in order to register our pre-track handler. We can wrap our `registerPreTrackCallback` invocation with `waitUntil`, in order to guarantee that it can be called on the `s` variable. From db998c3621823342e88cf822defe3d53ffc05a87 Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:51:13 -0500 Subject: [PATCH 7/8] Update README.md --- Integrations/Analytics/Adobe Analytics/Alignment/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index 0b9c467..56aa331 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -25,7 +25,7 @@ s.registerPreTrackCallback(function() { ### Adobe not guaranteed to load ahead of Optimizely Snippet -##### Recommended +#### Recommended Add the `holdEvents` call to the top of Project JavaScript @@ -41,8 +41,8 @@ Add this JavaScript code to your Adobe Analytics `s_code.js` file in the *plug-i window.optimizely.push({type: "sendEvents"}); ``` -##### Not recommended -Uses `setInterval` polling +#### Not recommended +> Uses `setInterval` polling We need to wait for the `s` variable to be defined in order to register our pre-track handler. We can wrap our `registerPreTrackCallback` invocation with `waitUntil`, in order to guarantee that it can be called on the `s` variable. From 6b3dc3c157eb0bff9e1d01d046511b87224d6c17 Mon Sep 17 00:00:00 2001 From: Cooper Reid Date: Wed, 6 Mar 2019 12:51:44 -0500 Subject: [PATCH 8/8] added number prefix --- Integrations/Analytics/Adobe Analytics/Alignment/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Integrations/Analytics/Adobe Analytics/Alignment/README.md b/Integrations/Analytics/Adobe Analytics/Alignment/README.md index 56aa331..b8240c3 100644 --- a/Integrations/Analytics/Adobe Analytics/Alignment/README.md +++ b/Integrations/Analytics/Adobe Analytics/Alignment/README.md @@ -9,7 +9,7 @@ Optimizely offers the [hold/send API](https://help.optimizely.com/Set_Up_Optimiz ## Two scenarios -### Adobe Loaded Ahead of Optimizely Snippet +### #1. Adobe Loaded Ahead of Optimizely Snippet Since Adobe is loaded first, we know the `s` variable is already defined by the time Optimizely Project JavaScript runs. We don't have to await it being defined. Hold events at the top of Project JS, register an Adobe pre-track handler that calls `sendEvents`. @@ -23,7 +23,7 @@ s.registerPreTrackCallback(function() { }); ``` -### Adobe not guaranteed to load ahead of Optimizely Snippet +### #2. Adobe not guaranteed to load ahead of Optimizely Snippet #### Recommended