Hubspot consent banner and PiwikPro tracking

A client uses the Hubspot consent banner on their website. We have implemented the Piwik Pro script directly into the website code and disabled the Piwik consent manager.

How do I manage the Piwik Pro tracking trigger with the HubSpot consent manager?

I have added the triggers below:

  • Page view with condition if cookie “__hs_initial_opt_in” = true (OK)
  • OR History change (SPA) with condition if cookie “__hs_initial_opt_in” = true ( Not working)

Piwik Pro tracking only works when the page reloads.


Is there dataLayer event sent with accepting cookies consent? Maybe add this one as well + cookie=true. Right now you are sending first entry page view with cookie=true (which is false), and then sending first page view on history change.

Maybe this workaround would help you.

1 Like

Hi @seo,

To have annonymous tracking as well I would recommend this set-up:

In administration > [site or app] > privacy:

  • ask visitor for consent - turned ON
  • Use a custom consent form - turned ON

Those settings will allow you to use consent manager methods without having our consent form shown to visitors.

Once you’ve done this part, now you should go to tag manager and create couple things:

  1. Custom JS Tag with this script in:
    window._paq = window._paq || [];'getComplianceSettings', (e)=>{
        if( !== 1) {
  'setComplianceSettings', {consents: {analytics: {status: 1}}}, ()=>{}, ()=>{});
    }, ()=>{});
  1. A trigger for the tag above that will fire on each page view where the cookie you’ve mentioned had value true.

Each new visitor is seen as anonymous by default so only after triggering this tag they will be seen as not anonymous.

With this kind of set-up you don’t have to worry about the additional condition for cookie value in each trigger you use, you simply set tags that you don’t want to fire for anonymous users as “consent type: analytics” and tags for every visitor “consent type: No consent is required”

In case you don’t want to track anything from anonymous users, than in administration > [site or app] > privacy you also change this:

This solution might take some time to set-up correctly and debug to make sure everything works as expected, so you might consider workaround of @Jakub_Fidala.


Unfortunately there is no dataLayer event with accepting cookies consent.

I added this tag and changed the setting as indicated but I think I missed something as the cookie seems to be there before the user choice.

Before accepting the cookies I see this in debug mode:

basic tracking code

Custom JS Tag

Trigger for Custom JS Tag

Administration > site > privacy

This tag should fire only when visitor give a consent. By the description of the situation, it sounds to me like the trigger is fired immidietly on the page, which by the look of the trigger (page load), I think is true. You have to use a cookie value that is only true once consent is given (or a cookie that is created only when consent is given).

The cookie (“__hs_initial_opt_in”) I’m relying on for the trigger is only true when the user consent.
I have sent you the site as a message. Can you please check it?

From what I see there is no ppms_privacy_<appID> cookie on the website, is it blocked by your consent manager? Consent manager requires this cookie to be present on site all the time to work properly. Here is more information about our cookies Cookies created for visitors by Piwik PRO | Data and cookies | Piwik PRO help center

Could Hubspot block this cookie? :expressionless:
I’m going to ask the client for more information.

I found Hubspot’s documentation for getting the consent status :

So I tried this (I am not web developer):

window._paq = window._paq || [];
var _hsp = window._hsp = window._hsp || [];

_hsp.push(['addPrivacyConsentListener', function(consent) {
    var analyticsConsent =;
    if (analyticsConsent !== true) {'setComplianceSettings', { consents: { analytics: { status: -1 } } });
        _paq.push(["setUserIsAnonymous", true]);
    } else {'setComplianceSettings', { consents: { analytics: { status: 1 } } });

but I still see this in debug mode (without clicking on the consent banner)… :

That’s correct, you should see it, as the current script you have should fire before consent is given. Because you are using a listener that waits for a decision. So the consent itself is not changed until listener sees the hubspot event.

What I’ve noticed is missing part of the script.
you need to have two functions at the end of set compliance settings. They are there for debugging purpose so I leave those empty but they are still required.
So instead of this:'setComplianceSettings', { consents: { analytics: { status: 1 } } });

You should have this:'setComplianceSettings', { consents: { analytics: { status: 1 } } }, ()=>{}, ()=>{});

Other thing is you are changing status for -1 for not consenting visitors. You should use 0, as -1 is interpreted as visitors who didn’t made decision yet. From the data gathering point there is no difference as Piwik PRO considers not consenting and those who didn’t made a decision yet as the same. But the proper way is to have 0 once someone doesn’t consent.

And last thing, when opening site as a new visit, I still don’t see our consent cookie, so please take a look at this issue.