Expand my Community achievements bar.

SOLVED

WebSDK - Data Object does not exist unless we set at least 1 thing in Update Variables

Avatar

Level 2

Hi,

 

I'm currently working on a migration from Tags to Event Forwarding.

 

I'm using Data Object instead of XDM as the client has an existing data layer and huge website and would like to avoid doing mapping in the report suite and Journey Analytics is in their future.

 

In my WebSDK Extension I'm using the On Before Send Event Callback Code to set my "global" variables, just how we would with doPlugins in the old AA extension.

 

I have a page load rule that fires a "Web Webpagedetails Page Views".

 

I have noticed that content.data is not defined in my CallBack Code if in my page load rule I do not add the action Update Variables and set at least one evar, prop, etc.

This seems like an unneeded extra step for a rule as some rules do not need to send extra evars etc, they just need to pass the "global" ones.

 

Has anyone found a work around for this, other than adding Update Variables to each rule?

 

Thanks!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Guess that's just how the devs implemented it. But at least they give you the commented lines to get started easily. 
What I typically do (coming from a classic analytics with AppMeasurement background and an "s" object) is

 

let s = content.__adobe.analytics.

 

this will let you work with the s object as you may have been used to.

Also, it has become so much better, you won't need to set any of

 

s.linkTrackEvents and

s.linkTrackVars

 

anymore.

Cheers from Switzerland!


View solution in original post

5 Replies

Avatar

Community Advisor

Hi @PaulBr15 

well, typically the payload should be a lean as possible and anything that is not needed is left out to improve the execution speed.

If you do not specify payload data, the WebSDK assumes there is no free form data that you want to send and keeps it empty.

 

This should not keep you from defining it your self in the onBeforeEventSend though.

Best practce should anyway always be checking if the object structure you want to add payload to exists.

 

So, add this at the beginning of your callback and it should be fine.

 

content.data = content.data || {};

 

Cheers from Switzerland!


Avatar

Level 2

Amazing thank you - makes sense. I've updated that and it works.

Whilst I've got you, another related question.

In Update Variables, we can set custom code, but, as per the pre-filled comment in the code, have to use the format of:

content.__adobe.analytics

Where as in the extension callback we use this format:


content.data.__adobe.analytics

Would you know the reason why they are different?

Thank you

Avatar

Correct answer by
Community Advisor

Guess that's just how the devs implemented it. But at least they give you the commented lines to get started easily. 
What I typically do (coming from a classic analytics with AppMeasurement background and an "s" object) is

 

let s = content.__adobe.analytics.

 

this will let you work with the s object as you may have been used to.

Also, it has become so much better, you won't need to set any of

 

s.linkTrackEvents and

s.linkTrackVars

 

anymore.

Cheers from Switzerland!


Avatar

Level 2

Love that, smart idea! Might have to steal that

 

And yes I'm loving having not to think about linkTrackEvents/Vars anymore

Avatar

Administrator

@PaulBr15 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni