I'm trying to figure out how to update an analytics event, when using the analytics template, within the update variable action.
I tired something like this:
content._experience = content._experience || {};
content._experience.analytics.event1to100 = content._experience.analytics.event1to100 || {};
content._experience.analytics.event1to100.event2.value = 1;
But I get an error: Failed to execute "Update variable" for "MY_Test" rule. Cannot set properties of undefined (setting 'value') TypeError: Cannot set properties of undefined (setting 'value')
Not sure what I'm missing here? I'm able to update props.
content._experience = content._experience || {};
content._experience.analytics.customDimensions.props = content._experience.analytics.customDimensions.props || {};
content._experience.analytics.customDimensions.props.prop1 = "Updated Prop1 Value";
content._experience.analytics.customDimensions.props.prop3 = "Updated Prop3 Value";
Thanks!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
I figured it out. You have to take it to the specific event:
content._experience = content._experience || {};
content._experience.analytics.event1to100.event2 = content._experience.analytics.event1to100.event2 || {};
content._experience.analytics.event1to100.event2.value = 1;
I figured it out. You have to take it to the specific event:
content._experience = content._experience || {};
content._experience.analytics.event1to100.event2 = content._experience.analytics.event1to100.event2 || {};
content._experience.analytics.event1to100.event2.value = 1;
alternatively, skipping the XDM schema, you could also leverage the data.__adobe.analytics object
content.__adobe = content.__adobe || { };
content.__adobe.analytics = content.__adobe.analytics || { };
let s = content.__adobe.analytics;
s.events = "events2";
// no linkTrackVars or linkTrackEvents needed
// also, you can set your props here
s.prop3 = "Updated Prop3 Value";
Which approach to choose is a general question to decide on.
I personally try to avoid using the XDM fieldgroup by any means, just because it makes your life so complicated.
Either you come up with data elements for everything or, like in your case, try to fill it with custom code and leaving you with this crazy bloated data structure.
Up to you
Views
Like
Replies