1
- var decisionString = window . optimizely . get ( 'state' ) . getDecisionString ( { campaignId : campaignId , shouldCleanString : true } ) ;
1
+ var decisionString = window . optimizely . get ( 'state' ) . getDecisionString ( {
2
+ campaignId : campaignId ,
3
+ shouldCleanString : true
4
+ } ) ;
2
5
var redirectInfo = window . optimizely . get ( 'state' ) . getRedirectInfo ( ) ;
3
6
var eVar = extension . eVar ;
4
7
var prop = extension . prop ;
5
- var campaignObject = { } ;
6
- if ( ! ! eVar ) campaignObject [ eVar ] = decisionString ;
7
- if ( ! ! prop ) campaignObject [ prop ] = decisionString ;
8
8
9
9
// Public Methods
10
10
var adobeIntegrator = {
11
- // Array of active campaigns/experiments
12
- campaignArray : [ ] ,
13
- // Accepts "s" variable as a param and assigns eVars to object.
14
- assignCampaigns : function ( sVariable ) {
11
+ campaignDecisions : { } ,
12
+ // Accepts "s" variable as a param and assigns eVars to object.
13
+ populateTrackerClearDecisions : function ( sVariable ) {
14
+ for ( var allocation in this . campaignDecisions ) {
15
+ sVariable [ allocation ] = this . campaignDecisions [ allocation ] ;
16
+ }
17
+ this . campaignDecisions = { } ;
18
+ } ,
19
+ assignCampaigns : function ( sVariable ) {
15
20
if ( ! ! redirectInfo ) sVariable . referrer = redirectInfo . referrer ;
16
- for ( var i = this . campaignArray . length - 1 ; i >= 0 ; i -- ) {
17
- Object . assign ( sVariable , this . campaignArray [ i ] ) ;
18
- this . campaignArray . splice ( i , 1 ) ;
19
- }
20
- } ,
21
- // Accepts "s" variable as a param and assigns eVars to object, then dispatches custom link tracking.
22
- trackDelayedCampaigns : function ( sVariable ) {
23
- for ( var i = this . campaignArray . length - 1 ; i >= 0 ; i -- ) {
24
- sVariable . linkTrackVars += "," + Object . keys ( this . campaignArray [ i ] ) [ 0 ] ;
25
- Object . assign ( sVariable , this . campaignArray [ i ] ) ;
26
- this . campaignArray . splice ( i , 1 ) ;
27
- }
28
- sVariable . tl ( true , "o" , "OptimizelyLayerDecision" ) ;
29
- }
21
+ this . populateTrackerClearDecisions ( sVariable ) ;
22
+ } ,
23
+ // Accepts "s" variable as a param and assigns eVars to object, then dispatches custom link tracking.
24
+ trackDelayedCampaigns : function ( sVariable ) {
25
+ this . populateTrackerClearDecisions ( sVariable ) ;
26
+ sVariable . tl ( true , "o" , "OptimizelyLayerDecision" ) ;
27
+ }
30
28
} ;
31
29
32
30
// Scopes `campaignArray` to Optimizely object.
33
31
if ( ! window . optimizely . get ( "custom/adobeIntegrator" ) ) {
34
- window . optimizely . push ( {
35
- type : "registerModule" ,
36
- moduleName : "adobeIntegrator" ,
37
- module : adobeIntegrator
38
- } ) ;
32
+ window . optimizely . push ( {
33
+ type : "registerModule" ,
34
+ moduleName : "adobeIntegrator" ,
35
+ module : adobeIntegrator
36
+ } ) ;
39
37
}
40
38
41
39
// Failing Audiences returns `null`, failing Traffic Allocation returns `undefined` for decisionString.
42
- if ( ! ! decisionString ) window . optimizely . get ( "custom/adobeIntegrator" ) . campaignArray . push ( campaignObject ) ;
40
+ if ( ! ! decisionString ) {
41
+ if ( eVar ) window . optimizely . get ( "custom/adobeIntegrator" ) . campaignDecisions [ eVar ] = decisionString ;
42
+ if ( prop ) window . optimizely . get ( "custom/adobeIntegrator" ) . campaignDecisions [ prop ] = decisionString ;
43
+ }
0 commit comments