Hey Community.
I'm currently looking for a look alike of getValOnce functionality.
Context:
When my users are processing an internal search, an event1 is being triggered once he land on search page results. If the user click on a product page, and then go back to the search page results the event1 will be trigger again.
My question is the following:
Is there any way to not send an event (here the event1) a second time if the keyword (eVarX) value hasn't changed since last time?
Thanks a lot for your help here.
Solved! Go to Solution.
Views
Replies
Total Likes
You could set a flag in sessionStorage or localStorage when event1 occurs. Then, you can read that back with a data element as a condition for whether you want to track event1 again.
You could set a flag in sessionStorage or localStorage when event1 occurs. Then, you can read that back with a data element as a condition for whether you want to track event1 again.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hello Yuhuisg,
I have another question regarding the tip you gave me.
So I tried to create a data element using sessionStorage with some custom code like this :
sessionStorage.setItem('searchTerm', digitalData.page.pageInfo.onsiteSearchTerm);
Then I added the following condition(also in custom code) to my rule which is sending the event1: The goal is to compare the eVar10 value with the new Data element I just created. If both value doesn't match, then event1 is being fired.
if(_satellite.getVar('Adobe Analytics - Search - Term') !== _satellite.getVar('Adode Analytics - Search - Term SessionStorage'));
So now I just have a last question because I'm not sure how to proceed. Once the event1 has been fired, I need to update the value of the 'Adode Analytics - Search - Term SessionStorage' but I'm not sure how to proceed here.
Do you have any advice here ?
Thanks a lot.
Views
Replies
Total Likes
@Swanan_that's actually the wrong approach. Your data element should use "sessionStorage.getItem()", not "sessionStorage.setItem()", since you're reading the sessionStorage's value. Tip: instead of using custom code to read the sessionStorage's value, you should use the Core > Session Storage data element type.
Then in your rule to send event1, you can have 2 actions: one does the comparison, and that should be inside an Adobe Analytics > Set Variables action's Custom Code. The other rule action is to run "sessionStorage.setItem()" to set the sessionStorage with your search term. Tip: you can use the 3rd party "SDI Toolkit" extension, which has a "Web Storage Setter" action type, to set your sessionStorage.
So, putting it all together, you have:
1. A data element of type Core > Session Storage, and the Session Storage Item Name is "searchTerm".
2. The rule that sends event1 has 2 actions:
2.1. Adobe Analytics > Set Variables: inside the Custom Code, use your "if" statement:
if(_satellite.getVar('Adobe Analytics - Search - Term') !== _satellite.getVar('Adode Analytics - Search - Term SessionStorage')) {
s.events = "event1";
// do other things
}
2.2 SDI Toolkit > Web Storage Setter: set the Item Key to "searchTerm" and Item Value to the data element for "digitalData.page.pageInfo.onsiteSearchTerm".
Views
Replies
Total Likes
Hello @yuhuisg, thanks again for your help on the subject. Everything is very clear.
I have one last question.
My rule which is sending event1 is sending another event at the same time (this one we need it every time).
Until now, the setup of this rule is the following :
Actions (only one action at the moment) > Adobe Analytics > Set Variables > Events > Event1 & Event36.
So I will delete the event1 from this action and create a new specific action with the custom code you mentioned.
As we specify in the custom code "s.events = event1", will it still count the first action and send the event36 then check if it needs to add event1? Or this will delete Event36 and send only event1?
The rest is super clear and again, thanks for your time and your help on this subject.
Views
Replies
Total Likes
@Swanan_it will delete event36 and keep event1. You should append event1 to the s.events string instead.
The safest way is to install the "Common Analytics Plugins", then enable the "apl" plugin. Then in your action's custom code, instead of using "s.events = 'event1'", you'd use
s.events = s.apl(s.events, 'event1');
Views
Replies
Total Likes
Hello @yuhuisg,
I finally solved my issue thanks to your advices. Thanks a lot.
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies