cookie banner and setting profile attribute | Community
Skip to main content
Michael_Soprano
Level 10
December 8, 2023
Question

cookie banner and setting profile attribute

  • December 8, 2023
  • 1 reply
  • 789 views

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?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Rajneesh_Gautam_
Community Advisor
Community Advisor
December 10, 2023

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

Michael_Soprano
Level 10
December 11, 2023

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

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