Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0
wesgardner

Stop Facebook Pixel triggering until consent is obtained (GDPR, EU Cookie Law)

Question

Interested to know if anyone has successfully blocked Squarespace's integration of Facebook Pixel from firing page views until consent has been obtained by the user?

Facebook's GDPR page recommends injecting this snippet to revoke consent until it is obtained and before the page view triggers:

fbq('consent', 'revoke');

The issue I'm having is that if I run that in a Code Injection before Squarespace's integrated Pixel code runs, the 'fbq' Javascript function is not defined yet. If I run it afterwards, the Pixel has already fired before consent has been obtained.

I'm after a pure Javascript solution to this; not interested in using a paid plugin.

Edited by wesgardner

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

I personally don’t know the solution with pure JavaScript however Style Factory wrote a blog post on how to achieve this with CookiesPro which is free if you have under 100 pages on your website. Obviously this won’t be any good for you if your website has more than 100 pages. 
 

https://www.stylefactoryproductions.com/blog/create-gdpr-compliant-squarespace-cookie-banner

Edited by ThompsonWebDesign

If you see an answer that was helpful please consider hitting the 121238226_Screenshot2019-11-02at14_53_39.png.0416997a5e856e0159fa1edbd624659e.png button on the right. 

Need help with your website or online store? Feel free to get in touch.

thompsonweb.design

Share this post


Link to post
  • 0

Hi @wesgardner.  The issue you're having makes sense because fbq('consent', 'revoke'); needs to happen after fbq is initialized but before fbq("track"...) is run. When you're using Squarespace's built-in integration, you can't get "between" those two with your own code.

To work around it, you'll want to stop using the built-in integration and instead insert the FB tracking code on your own, via code injection. Then you can work with it with more granularity. The next step is detecting when the user consents via Squarespace's built-in cookie banner. Looking past the shortfalls of this banner in terms of compliance, this can be done a number of ways.

Are you also using Google Analytics? A similar approach would apply there, and could be handled together in the same script. GA doesn't offer a "grant consent" method like FB does, but that's not a big deal.

Do you have a template with AJAX loading and is it enabled? In theory, Facebook should deal with this itself since it uses the history state API listener, but GA (if you're using it) would require updating the page_path parameter.

-Brandon

Edited by brandon

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...