bigcommerce / cornerstone

The BigCommerce Cornerstone theme
https://developer.bigcommerce.com/stencil-docs
288 stars 601 forks source link

Feature Request: Access Shopper Content Tracking in Stencil/Handlebars #1953

Open Tiggerito opened 3 years ago

Tiggerito commented 3 years ago

I'm developing an app that includes a script that covers multiple different levels of user consent (Essential, Analytics, Functional, Advertising).

Because of this I can't use the script category options in the script manager. And the code is too integrated to easily split it up into sub scripts for each level of consent.

The Stencil object contains a property to indicate if consent tracking is on (shopper_consent_tracking_enabled). It would be nice if it also indicated the current users settings. That way I could use handlebars to only include code when it is allowed. e.g.

{{#if shopper_consent_tracking.analytics}}
// analytics code here
{{/if}}

At the moment I am examining the consent tracking cookie to determine the users options. This is obviously unreliable as its an undocumented feature. It changed from 'tracking-preferences' to 'bc_consent' recently, to prove that point.

Tiggerito commented 1 year ago

Update.

BigCommerce now supports a single-page consent banner which enables scripts on the fly. I support that by continually monitoring the bc_consent cookie and enabling our scripts if we see consent granted.

I've also created a function to help third-party consent banners update the consent status and enable scripts on the fly. That way, these alternate banners integrate well with BCs consent system. To make this work the BC consent banner needs to be switched on and then hidden.