Block trekkie before GDPR cookie consent

Highlighted
Shopify Partner
1 0 1

Hi there,

I'm working on Shopify with Split theme. I need to block all the cookies loaded by Shopify when the user is visiting the website the first time, then after the consent is given I can load all the libraries that are using cookies.

I see that Split theme is using the "trekkie" library to load Facebook, Google and so on...

I have to replace: <script class="analytics"> (where trekkie is placed by shopify) with <script type="text/plain" class="analytics _iub_cs_activate-inline">.

In this way, after consent is given, iubenda will replace all the script with "text/plain" and class="_iub_cs_activate-inline" with <script type="text/javascript" and all my cookies will be loaded.

Unfortunately I'm not able to access the trekkie part of the theme. Do you have any hints about how I can access it?

Please let me know,
Thank you in advance.

Have a nice day.

1 Like
Highlighted
New Member
2 0 0

Hello,

 

I do have the same trouble, I am trying to use Cookiebot or Tarteaucitron in order to display a cookie banner wich allow user to choose their cookies but both apps are blocked due to trekkie ...

 

Shopify, could you help us ?

Currently, there is no cookie banner app 100% compliant with RGPD law :(

0 Likes
Highlighted
Excursionist
21 0 24

Not sure if this helps, but response I got a couple months ago from the 'Shopify Privacy Team' to a similar question is pasted below.

 

..."Some of the cookies are necessary for the service (for example populating the cart). Some are for analytics purposes. You can see the list of each here (https://www.shopify.com/legal/cookies).

 

If you want to disable Shopify's analytics service, you can customize your theme on your storefront to remove the "content for header" object (which initiates the analytics service). Alternatively, if you are not looking to disable the service altogether, you can make the "content for header" object conditional on whatever third party cookie banner code you are using, so the "content for header" object is only activated when a user consents via your cookie banner."

 

 

I personally am more worried that Shopify fobs-off GDPR-compliant cookie consent to 3rd party developers in the first place. To me this is core functionality Shopify should provide. See my other post here.

0 Likes
Highlighted
New Member
1 0 0

Hey aj007, I've also gotten the run-around from Support on this issue. They told me to hire an Expert. The Expert said "no idea".

 

Did you have any luck implementing their "content for header" suggestion? I would've thought this would disable a bunch of other presumably important stuff as well.

0 Likes
Highlighted
Excursionist
34 1 5

Just wondered if anyone had implemented a consent model for Shopify Analytics.  We are clear on what we need to do, for example adding something to the script tag class="optanon-category-2 or injecting something through GTM, I just wondered if anyone had actually implemented anything

 

Thanks

0 Likes
Highlighted
Tourist
3 0 2

This came up at work for OneTrust, and I'm posting my solution here for anyone that might come across it. Essentially, we don't want to nix the entire {{content_for_header}} object because it includes other scripts aside from analytics. 

 

Luckily, Shopify does add a class to the analytics script. Therefore, we need to capture it and then utilize the replace filter, like so:

 

{% capture header_capture %}
  {{ content_for_header }}
{% endcapture %}


{{header_capture | replace: '<script class="analytics">', '<script type="text/plain" class="optanon-category-2">'}}  

 

Edit: I also found that the scripts denoted with `class="optanon-category-x` don't reset to the "text/plain" type without a reload, so depending on your application, you may need something like:

 

const optanonButtons = document.querySelectorAll('.optanon-button-wrapper');

if ( optanonButtons ) {
    for ( let i = 0; i < optanonButtons.length; i++) {
      optanonButtons[i].addEventListener('click', () => {
        location.reload();
      })
    }
}

 

1 Like
Highlighted
Tourist
3 0 2

const optanonButtons = document.querySelectorAll('.optanon-button-wrapper');

if ( optanonButtons ) {
    for ( let i = 0; i < optanonButtons.length; i++) {
      optanonButtons[i].addEventListener('click', () => {
        location.reload();
      })
    }
}

 


I wanted to add to my last reply - instead of attaching event listeners to the button you can simply write your functions inside the supplied OptanonWrapper function and it will update. 

0 Likes
New Member
4 0 0

Does this coding work for Brooklyn or other themes? Quite new to the coding but would like to follow best steps forward!

0 Likes
Highlighted
Excursionist
34 1 5

Hi valespring

 

This is interesting and something I am working on.  One question, after doing

 

<script type="text/plain" class="optanon-category-4">

 

What to I need to do to enable the script?

 

Thanks

 

Grant

0 Likes
Highlighted
Tourist
3 0 2

@GrantDB wrote:

Hi valespring

 

This is interesting and something I am working on.  One question, after doing

 

<script type="text/plain" class="optanon-category-4">

 

What to I need to do to enable the script?

 

Thanks

 

Grant


This is the default behavior for Onetrust. You set the script to "text/plain" and the category to whatever these scripts fall under. For us, these are targeting cookies. Then, once cookies are accepted for that category(4), Onetrust's script removes the script type and everything inside fires.

 

https://community.cookiepro.com/s/article/UUID-730ad441-6c4d-7877-7f85-36f1e801e8ca

 

 

1 Like