What would happen if the events are set in both Adobe Analytics Extension AND custom code inside rules using s (tracker object)? | Community
Skip to main content
Level 2
January 28, 2024
Question

What would happen if the events are set in both Adobe Analytics Extension AND custom code inside rules using s (tracker object)?

  • January 28, 2024
  • 2 replies
  • 2235 views

I am setting my events for Adobe Rules. I have set them as follows in Adobe Analytics Extention. 

 

However, I can see the same events being set in the custom code section of the rules. 

 

 

Does this mean that I am getting duplicate results in the analytics dashboard? 

What is the purpose of custom code setting if I can set events using the extension? 

 

Thanks in advance! 

 

2 replies

abhinavbalooni
Community Advisor
Community Advisor
January 28, 2024

Hey @supund 

 

If both the mappings are in the same rule, the custom code would overwrite your UI mappings. Usually, custom code has this kind of mapping when you need to have some custom checks before mapping the variables.

 

It will not duplicate your numbers, but whatever you are setting in custom code, would overwrite your UI mapping. If you already have those events mapped in custom code, you don't need to set them through the UI.

 

Cheers,

Abhinav

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 28, 2024

The custom code is run after the "Set Variables" interface code, so I agree with @abhinavbalooni, the custom code should overwrite anything set in the UI in this example.

 

If you need to merge the UI set values with custom values, you should be able to append the values with something like:

 

s.events += ",eventX,eventY";

 

 

But since you are comfortable enough with JS, you can just do it all in custom code (for the record, that is how I do my events for page views and actions... they are all set in custom code, where I can run extra logic checks for when they should be included).

SupunDAuthor
Level 2
January 29, 2024

Thanks @jennifer_dungan @abhinavbalooni

 

When I have both the custom code and event set up in rules UI, I see a double number of hits on Adobe Analytics. However, when I take the custom code out and only keep the event set up on the UI, the number of hits halves (i.e. More or less half the value of hits compared to having both UI and custom code).

 

Any idea why it is behaving this way? (This is why I was initially under the impression that when I have both the UI and custom code set up, the event gets fired twice) 

 

abhinavbalooni
Community Advisor
Community Advisor
January 29, 2024

@supund Two possibilities:

 

1. Another rule triggering with similar set of variables.

2. If you have an s.tl() call in the custom code in the rule and Also have a send beacon action in the rule.

 

Check if any of the above scenarios exist for you.

 

Cheers,

Abhinav