Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate cookie layer with data-domain #220

Closed
verlok-cn opened this issue Dec 14, 2022 · 2 comments · May be fixed by #269
Closed

Integrate cookie layer with data-domain #220

verlok-cn opened this issue Dec 14, 2022 · 2 comments · May be fixed by #269
Assignees
Labels
frontend UI and block related

Comments

@verlok-cn
Copy link

verlok-cn commented Dec 14, 2022

As a web performance consultant, I need to track which page views were viewed with the cookies accepted and which ones with cookie refused, so that I will be able to quickly check on the impact of third parties.

In order to do that, we require that, when users make a choice by clicking on the cookie layer "accept" "refuse", etc. the data-wp-page-cookie attribute of the <main> tag is updated via JavaScript with the resulting value.

The value data-wp-page-cookie is a string, containing any value that would make us able to distinguish which page views were made after users accepted what.

Some examples could be:

  • all-accepted
  • none-accepted
  • an array of accepted cookie types, e.g. marketing, technical, ...

Sample code, just to give you the idea:

const acceptedCookies = someFunctionToGetTheValues();
let elementWithTheCookieAttribute = document.querySelector('[data-wp-page-cookie]');

if (!elementWithTheCookieAttribute) {
  // this should never be the case because the attribute 
  // is already in the `main` tag
 elementWithTheCookieAttribute = document.createElement(`div`);
 document.body.appendChild(elementWithTheCookieAttribute);
}

elementWithTheCookieAttribute.setAttribute('data-wp-page-cookie', acceptedCookies.join());

Related ticket: #72.

@verlok-cn
Copy link
Author

@NCalexiaeche what do I need to do for this ticket?

@verlok-cn
Copy link
Author

Tested in prod, and working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend UI and block related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants