Expand my Community achievements bar.

The Analytics Community Lens news letter for February 2024 is now here! Come see upcoming events and what's been going on in the community!

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

Avatar

Level 3

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

 

image (77).png

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

 

2024-01-29_09-06.png

 

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! 

 

Topics

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

7 Replies

Avatar

Community Advisor

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

Avatar

Community Advisor

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).

Avatar

Level 3

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) 

 

Avatar

Community Advisor

@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

Avatar

Level 3

Hi @abhinavbalooni

 

I have a beacon set up as follows 

 

SupunD_0-1706496903345.png

Does this have any effect on duplicate data? 

 

Thanks in advance! 

Avatar

Community Advisor

@SupunD 

Can you QA at your end if this rule triggers two analytics calls ? If yes, then along with this send beacon there might well be another s.tl() method being called in your rule.

 

To check if the rule triggers more than once, you can run _satellite.setDebug(true) command on your developer console and check.

 

If it does indeed trigger two analytics calls, try removing this send beacon action and see if you get one call instead of two.

 

Cheers,

Abhinav

Avatar

Community Advisor

Good advice @abhinavbalooni 

 

Only the "Send Beacon" action (where you choose the s.t() call), and manually setting "s.t()" in your code will send a beacon.

 

However, if the rule is triggered twice in quick succession, or multiple rules are triggered, that could cause multiple tracking calls.

 

If you see two different rules being triggered (using the debug code), then you may have to add conditions to ensure that there is no overlap on triggers, or merge the two rules into one. (This may still cause multiple calls, but the next solution will help to solve it).

 

If you see the same rule triggered twice in a row, you can add a "Max Frequency" condition on the rule... generally the:

"Return true no more than once every 1 seconds" is sufficient

Jennifer_Dungan_0-1706500137484.png

 

This should prevent the same rule from being triggered twice in a row.

 

 

 

Based on the screenshot of the custom code, nothing there should trigger double tracking. I don't any see custom code to send a beacon (unless more code was added since), and there is nothing there that should cause any sort of potential looping or duplication event...