Expand my Community achievements bar.

Take 10 minutes to complete an Adobe Target review on Gartner Peer Insights, and as a thank you for your time, you’ll have the option to receive a $25 gift card!

cookie banner and setting profile attribute

Avatar

Level 7

Hi, 

I am creating cookie banner and I would like to divide users on two groups based on the button which they clicked. How would you approach that tasks? Set up event listener for the buttons and then set some profile attributes? Can I add this in the experience script? How would you approach that?

 

Michael_Soprano_0-1702038763170.png

 

Topics

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

2 Replies

Avatar

Community Advisor

Hi @Michael_Soprano  - before we go into the technical solution, let me try to understand the expected behaviour when a customer clicks "Decline". Will such customers be excluded from showing any personalised experience, including AB tests? In other words, will they be part of any experience driven by Adobe Target?

If the answer is yes, then recommended approach should be to block Adobe Target call altogether using your Tag Management System. The idea should be to respect customer's choice.

However, if its only limited to Personalisation but not AB tests (would suggest confirming this with your company's DPO - Data Protection Officer) then here's the solution:

1. Pass a flag corresponding to which button customer clicked as an mbox-parameter through trackEvent() method, by adding following code to buttons' event-listener:

adobe.target.trackEvent({
 "mbox": "track_customer_preference",
 "params": {
   "preference": "accepted" //or declined
  } 
 });

2. Create a profile-script using this parameter

if(mbox.name == "track_customer_preference" && mbox.param("preference")) {
return mbox.param("preference"); // will return either "accepted" or "declined"
}

3. Use the profile-attribute in your activities as audiences.

 

Hope it helps,

 

Regards

Rajneesh

Avatar

Level 7

Thanks a lot. 

 

Hi @Michael_Soprano  - before we go into the technical solution, let me try to understand the expected behaviour when a customer clicks "Decline". Will such customers be excluded from showing any personalised experience, including AB tests? In other words, will they be part of any experience driven by Adobe Target?

 

It is for the demo purposes so it does not matter yet a lot but it is definetely food for thought for me and I will also prepare this scenario in my list of use-cases.

 

1. Pass a flag corresponding to which button customer clicked as an mbox-parameter through trackEvent() method, by adding following code to buttons' event-listener:

 

I implemented code like this: 

<script type="text/javascript">
        let x = document.createElement('div');
        x.setAttribute('id', 'cookie');
        x.innerHTML = `
           <div class='cookie'> someHTML ... </div>
        `;
        document.body.append(x);
        let accept = document.querySelector('.accept');
        accept.addEventListener('click', () => {
        console.log('accepted');
        adobe.target.trackEvent({
            "mbox": "track_customer_preference",
            "params": {
            "preference": "accepted" //or declined
        }})
        x.style.display = 'none'
        });
</script>
 
Banner shows up but I cannot close it. If I would like to close the banner this error shows up....

Michael_Soprano_0-1702293255203.png

It looks like adobe global function is not available. How to resolve this bug?