Modify standard footer template to avoid automatic Ad Pixels / Cookiebot GDPR compliance

SOLVE
joergschaeffer
Participant

My question:

Is there any way to modify or override the Hubspot standard modules  ("{{ standard_header_includes }}" / "{{ standard_footer_includes}}")  that are referenced from the base.html pages in the theme and load some HubSpot specific code modules?

 

Longer story with reasoning:

My company is based inside the EU and we use Cookiebot as our Cookie Consent Management solution which also supports "prior consent" - which means as long as the end user does not make a choice, no third party scripts are ever loaded and cookies set.

 

E.g. we load all our ad pixels via Google Tag Manager which in turn is enabled through explicit user consent for "Marketing Cookies".

 

This technically works by modifying the Javascript embed tag from

<script language="text/javascript">

to 

<script language="text/plain" data-cookieconsent="marketing">

 

Cookiebot then works to load the tagged scripts according to the user preferences.

 

I have embedded Cookiebot into my base.html template in the <head> section and it loads fine.

 

I have also added Google Analytics and Google Tag Manager into the base.html and configured them to be loaded when the user has given appropriate consent for "Statistics" or "Marketing". That works fine too.

 

However, when I set up Ad Pixels in the Ads section of the Marketing Professional product, HubSpot insists on loading the ad pixels through the HubSpot JS Code autmatically which breaks the user consent.

 

Also the HubSpot tracking code always runs and cannot be attributed to a Cookie Consent value for Cookiebot.

 

Plus the standard Hubspot templates always include Twitter, Facebook and LinkedIn SDKs which is also not desirable from a privacy perspective if they are not needed.

 

My question:

Is there any way to modify/override the standard templates that wrap the theme and load the HubSpot specific code modules?

 

E.g. in the header I want to remove

<script src="//platform.linkedin.com/in.js" type="text/javascript">
lang: en_US
</script>

 

0 Upvotes
1 Accepted solution

Accepted Solutions
joergschaeffer
Solution
Participant

And for the GDPR compliance modification of script loading tags with Cookiebot, I did the following in my base.html and base_landing.html by adding a filter to the standard_footer_includes macro:

 

{{ standard_footer_includes|replace('type="text/javascript" id="hs-script-loader"','type="text/plain" id="hs-script-loader" data-cookieconsent="marketing"') }}

 

Whilst this may not be the most elegant solution, it does the job:


- The main HubSpot script loader for analytics and tracking is only loaded when the Cookiebot Consent for "Marketing" cookies exists.

- No HubSpot tracking is done before the user has given Marketing Consent.

- The main HubSpot script then also loads any Ad Pixels configured in HubSpot for Google, LinkedIn and Facebook Ads. These Ad Pixels need to be removed in our Google Tag Manager Setup then.

 

Please note that you have to include the Cookiebot script in the head section of your base.html too for this to work obviously.

If you want Google Tag Manager or Google Analytics to load by other permissions (i.e. "necessary", "statistics") then the scripts for these tools cannot be loaded through the HubSpot main script but need to go into the base.html directly hardcoded.

View solution in original post

0 Upvotes
2 Replies 2
joergschaeffer
Participant

Sometimes the solution can be too simple:

I overlooked the Blog Settings where you have checkboxes to select which Social Network Sharing buttons you want active.
By deactivating the checkboxes, the <script> loading tags for LinkedIn, Twitter and Facebook are disabled and not appearing in the standard_header_includes or standard_footer_includes.

Screen Shot 2020-10-16 at 18.30.21.png

0 Upvotes
joergschaeffer
Solution
Participant

And for the GDPR compliance modification of script loading tags with Cookiebot, I did the following in my base.html and base_landing.html by adding a filter to the standard_footer_includes macro:

 

{{ standard_footer_includes|replace('type="text/javascript" id="hs-script-loader"','type="text/plain" id="hs-script-loader" data-cookieconsent="marketing"') }}

 

Whilst this may not be the most elegant solution, it does the job:


- The main HubSpot script loader for analytics and tracking is only loaded when the Cookiebot Consent for "Marketing" cookies exists.

- No HubSpot tracking is done before the user has given Marketing Consent.

- The main HubSpot script then also loads any Ad Pixels configured in HubSpot for Google, LinkedIn and Facebook Ads. These Ad Pixels need to be removed in our Google Tag Manager Setup then.

 

Please note that you have to include the Cookiebot script in the head section of your base.html too for this to work obviously.

If you want Google Tag Manager or Google Analytics to load by other permissions (i.e. "necessary", "statistics") then the scripts for these tools cannot be loaded through the HubSpot main script but need to go into the base.html directly hardcoded.

View solution in original post

0 Upvotes