# 3rd Party Custom Consent Manager JS API Issue

**URL:** <https://community.piwik.pro/t/3rd-party-custom-consent-manager-js-api-issue/527>\
**Category:** API & integrations\
**Created:** [March 18, 2022, 1:28pm UTC](https://community.piwik.pro/t/3rd-party-custom-consent-manager-js-api-issue/527 "2022-03-18T13:28:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@Tom](https://community.piwik.pro/u/Tom)\
**Post date:** [March 18, 2022, 1:28pm UTC](https://community.piwik.pro/t/3rd-party-custom-consent-manager-js-api-issue/527/1 "2022-03-18T13:28:00Z")

</div>

Hi,

I’m currently trying to use a 3rd party CMP (Cookiehub) integrated into Piwik Pro using tag manager and Piwik Pro’s JS consent API to feed the user’s consent into Piwik Pro.

So far I’ve managed to activate the consent for each category (aligned with the 3rd party consent category’s) which responds to both allowing cookies and declining them, however it’s resulting in 6 consent decisions showing up (one for each category as they change from no to yes) instead of one with them all on.

I realise that this is happening because there is a separate API call for each category, however when I attempt to put multiple categories within the same line, it only ever activates one of them…

eg.

```auto
ppms.cm.api('setComplianceSettings', {consents: {analytics: {status: 1}} && {remarketing: {status: 1}} }, function(){}, function(){});

```

My code with seperate lines:

```auto
<script type="text/javascript">
var cpm = {
	onAllow: function(category) {
		if (category == 'analytics') {
          ppms.cm.api('setComplianceSettings', {consents: {analytics: {status: 1}}}, function(){}, function(){});
		}
      
        if (category == 'marketing') {
      	  ppms.cm.api('setComplianceSettings', {consents: {remarketing: {status: 1}}}, function(){}, function(){});
		}
      
        if (category == 'preferences') {
      	  ppms.cm.api('setComplianceSettings', {consents: {ab_testing_and_personalization: {status: 1}}}, function(){}, function(){});
		}
      
        if (category == 'analytics') {
      	  ppms.cm.api('setComplianceSettings', {consents: {conversion_tracking: {status: 1}}}, function(){}, function(){});
		}
      
        if (category == 'marketing') {
      	  ppms.cm.api('setComplianceSettings', {consents: {marketing_automation: {status: 1}}}, function(){}, function(){});
		}
      
        if (category == 'analytics') {
      	  ppms.cm.api('setComplianceSettings', {consents: {user_feedback: {status: 1}}}, function(){}, function(){});
		}
      
	},
	onRevoke: function(category) {
		if (category == 'analytics') {
          ppms.cm.api('setComplianceSettings', {consents: {analytics: {status: 0}}}, function(){}, function(){});
		}
      
        if (category == 'marketing') {
    	  ppms.cm.api('setComplianceSettings', {consents: {remarketing: {status: 0}}}, function(){}, function(){});
		}
      
        if (category == 'preferences') {
      	  ppms.cm.api('setComplianceSettings', {consents: {ab_testing_and_personalization: {status: 0}}}, function(){}, function(){});
		}
      
        if (category == 'analytics') {
      	  ppms.cm.api('setComplianceSettings', {consents: {conversion_tracking: {status: 0}}}, function(){}, function(){});
		}
      
        if (category == 'marketing') {
      	  ppms.cm.api('setComplianceSettings', {consents: {marketing_automation: {status: 0}}}, function(){}, function(){});
		}
      
        if (category == 'analytics') {
      	  ppms.cm.api('setComplianceSettings', {consents: {user_feedback: {status: 0}}}, function(){}, function(){});
		}
      
	},
  
};
(function(h,u,b){
var d=h.getElementsByTagName("script")[0],e=h.createElement("script");
e.async=true;e.src='https://cookiehub.net/c2/xxxxxxxx.js';
e.onload=function(){u.cookiehub.load(b);}
d.parentNode.insertBefore(e,d);
})(document,window,cpm);
</script>

```

The result:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/piwikpro/original/1X/07fdca4ede38dbd6e39ac11d38af7ff3ebf122b4.jpeg)

Any help on this issue would be much appreciated!

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 18, 2022, 2:37pm UTC](https://community.piwik.pro/t/3rd-party-custom-consent-manager-js-api-issue/527/2 "2022-03-18T14:37:20Z")

</div>

In general, it should work. Just correct the json object you pass:

```auto
{consents: {analytics: {status: 1}, remarketing: {status: 1}}}

```

---

<div class="post-metadata">

**Author:** ![michiel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/michiel/32/236_2.png) [@michiel](https://community.piwik.pro/u/michiel)\
**Post date:** [March 22, 2022, 6:31am UTC](https://community.piwik.pro/t/3rd-party-custom-consent-manager-js-api-issue/527/3 "2022-03-22T06:31:34Z")

</div>

@Tom, @Admin,  
This is great! We’re using Cookiebot instead of Cookiehub, but I’m really interested in getting this to work. Would this work for Cookiebot as well?

As the Tag Manager doesn’t allow for trigger groups at the moment, I built a custom event to check marketing consent before triggering a Facebook conversion for example. Would be great if that would work with the consent settings for the conversion tag.

Any pointers where to start?

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 22, 2022, 10:04am UTC](https://community.piwik.pro/t/3rd-party-custom-consent-manager-js-api-issue/527/4 "2022-03-22T10:04:13Z")

</div>

Yes, additional datalayer events are a nice workaround. I’m sure that trigger groups will be added somewhere along the road.

Integrating with external consent manager is all about checking their api and events meaning that a certain consent has just been given. We have plans to publish official integrations for onetrust and cookiebot but there’s no eta yet.
