How should CMPs be deployed in light of script tags for templates and JS API being modernized

In light of this announcement (Modernizing inline script tags for templates & JS API), script type =’text/discourse-plugin or script type=’text/x-handlebars’ have been deprecated.

However, it is essential in the EU & UK to have a CMP (consent management platform), in order to collect for ads and tracking.

This includes AdSense, GAM, Google Analytics and most other vendors. Without a CMP, almost no ads will show and site owners will be breaking privacy and consent laws.

What is the best practice for implementing CMP script moving forward?

Previously I had code in the header but I now receive admin errors and it seems this will get nuked in September. An example of the code I am using below:

My site is gasroom.org

Thank you!

You can move this code to the ‘JS’ tab in a theme (under ‘Edit CSS/HTML’), without the script tags. Put this code within the apiInitializer part.

Then, you can change Discourse.user.current() to something like api.getCurrentUser().

1 Like