How can I integrate a third-party cookie consent tool with Piwik PRO?

Administration

Needed permissions: owner

If you want to keep using your cookie consent tool and don’t want to switch to our Consent Manager, you can integrate it with Piwik PRO. This way, you’ll be able to collect full data from visitors who gave their consent and anonymous data from the others. In this article, we’ll explain how to set it up.

Before you start

Here are some things to know before you integrate Piwik PRO with a third-party cookie consent tool:

  • You can use this integration for Cookiebot, OneTrust, Termly and the like.
  • Our consent mechanism works together with Tag Manager. Each tag in Tag Manager has a consent type and is fired only if consent is given (There’s also a no-consent-required type). This integration shows how to synchronize the analytics consent type between your cookie consent tool and Piwik PRO.
  • You need to install our container’s code on each page of your website. Read more
  • The Piwik PRO tag (tracking code) in Tag Manager needs to have the consent type: Analytics. (That’s a default setting.)
  • You’ll need to add some JavaScript methods to your website’s source code, so you might need help from a web developer. These methods make the visitor non-anonymous. But if you can’t do that, you can collect anonymous data from all visitors.
  • If you want to synchronize other consent types, use our JavaScript methods.
  • This integration doesn’t collect or pass consent statistics. But, you can use our JavaScript methods to create such integration.

To integrate Piwik PRO with a third-party cookie consent tool, follow these steps:

  1. Log in to Piwik PRO.
  2. Go to Menu > Administration.
  3. Navigate to Sites & apps.
  4. On the left, pick the site or app you want to set up.
  5. Navigate to Privacy.
  6. Turn on Ask visitors for consent.
  7. In When visitors don’t consent, you can pick one option:
    • Collect data using a 30-minute cookie: You’ll use a 30-minute cookie to collect session data. You won’t recognize new and returning visitors, but you’ll get data on the visitor’s country. Visitors’ IP addresses will be fully masked.
    • Collect data without using cookies (recommended): You won’t create or store any cookies on visitors’ browsers. Nothing will be stored on visitors’ devices. You won’t recognize new and returning visitors, but you’ll get data on the visitor’s country. Visitors’ IP addresses will be fully masked.

    Note: Some triggers in Tag Manager create cookies to function correctly. If you use one of the following conditions in triggers, we’ll set a cookie:

    • Event condition > Traffic source
    • Event condition > Returning visitor
    • Event condition > Campaign
    • Event condition > External referrer 
    • Multiplicity > Fire tag once per session
    • Multiplicity > Fire tag multiple times per session, excluding first
    • Multiplicity > Fire tag once per page view

    Make sure that tags with those triggers are set with the right consent type.

    We also set essential cookies that store visitor’s consent decision. More about cookies

    • Don’t collect data: The tracking code won’t be fired for visitors.

    Note: We observed on our sites that only 25 to 75 percent of people give full consent. So you may want to collect non-sensitive data from visitors who don’t agree to data collection and usage.

  8. Turn on Use a custom consent form.
  9. Click Save.
  10. In your website’s source code, call the setInitialComplianceSettings() method when a consent banner is visible for a visitor.
    ppms.cm.api(
      "setInitialComplianceSettings",
      {
        consents: ["analytics"],
      },
      console.log,
      console.error
    );

    Note: For non-anonymous visitors, Piwik PRO sets a first-party cookie, creates a session ID, unmasks IP address and reads full location data (Latitude, Longitude, Organization, Provider, City, Region, Country, Continent). Read more

    Note: You can skip this step and collect anonymous data from all visitors.

    Tip: You might need to ask for help your web developer to add these methods to your site’s source code.

  11. Call the setComplianceSettings() method when a visitor agrees to analytics on your third-party consent form. This will make the visitor non-anonymous.
    ppms.cm.api(
      "setComplianceSettings",
      {
        consents: {
          analytics: {
            status: 1,
          },
        },
      },
      console.log,
      console.error
    );
  12. All done! Now Piwik PRO will collect full data from visitors who gave the consent and anonymous data from others.

Was this article helpful?

Technical support

If you still have any questions, visit our community.
There’s always someone happy to help!

Back to help center