Can I use Piwik PRO and Matomo at the same time?

Yes, you can use Piwik PRO and Matomo together, but you need to make some changes to track all your data correctly.

Both Piwik PRO and Matomo use the _paq.push() command to send data. This is because both tools come from the same open-source product. In Piwik PRO we’re working on changing the _paq.push() command to _ppas.push() so that it doesn’t interfere with Matomo. But before we do that, you need to use the manual setup.

The setup can be done in two ways : (1) using a modified Piwik PRO tracking code and Matomo tracking code (2) using only the Matomo tracking code but modifying it.

Option #1: Use a modified Piwik PRO tracking code and Matomo tracking code

Option #1 is good if you want a completely separate setup for Piwik PRO and Matomo. It requires a little more custom code, but it allows you to use all of our features, some of which Matomo doesn’t have. In this method, you keep the Matomo tracking code as it is and modify the Piwik PRO tracking code.

To modify the Piwik PRO tracking code, follow these steps:

  1. Log in to Piwik PRO.
  2. Go to Menu > Tag Manager.
  3. Navigate to Tags.
  4. Name your tag and select the following type: Custom code (async).
  5. In Tag code, add the following code:
    <!-- Piwik PRO -->
    <script type="text/javascript">
        var _ppas = _ppas || [];
        _ppas.push(['setUserIsAnonymous', 1]);
        _ppas.push(["trackPageView"]);
        _ppas.push(["enableLinkTracking"]);
        (function() {
            var u = "https://example.piwik.pro/";
            _ppas.push(["setTrackerUrl", u + "ppms.php"]);
            _ppas.push(["setSiteId", "XXX-XXX-XXX-XXX-XXX"]);
            var d = document,
                g = d.createElement("script"),
                s = d.getElementsByTagName("script")[0];
            g.type = "text/javascript";
            g.async = true;
            g.defer = true;
            g.src = u + "ppas.js";
            s.parentNode.insertBefore(g, s);
        })();
    </script>

    Parameters

    https://example.piwik.pro/
    The address you use to log in to Piwik PRO.

    XXX-XXX-XXX-XXX-XXX
    The ID of the site or app in Piwik PRO where you want to send data. (Where to find it?)

  6. In Advanced tag settings, choose Consent type: No consent is required.
  7. In Tag triggers, add the following trigger: All page views.
  8. Click Save.
  9. Go to Tags.
  10. Click Add a tag again. Now you need to add a tag responsible for deanonymizing the user who consents to data collection.
  11. Name your tag and select the following type: Custom code (async).
  12. In Tag code, add the following code:
    <script>
      _ppas.push(['deanonymizeUser']);
    </script>
  13. In Advanced tag settings, choose Consent type: Analytics.
  14. In Tag triggers, add the following trigger: All page views.
  15. Click Save.
  16. Test your tag in debug mode.
  17. Deactivate the following tag: Piwik PRO (tracking code). This code is responsible for data collection, but you’ll use a modified version.

    Note: If you get an error saying: “Matomo javascript tracker or Piwik PRO javascript tracker was already initiated on this page,” it’s very likely that you haven’t deactivated this tag and now you have two Piwik PRO scripts running.

  18. Click Publish.
  19. Done!

How to use custom events and goals

The _paq.push() command is also used in custom events and goals, so you’ll need to use the manual setup to set them up.

To add a custom event, follow these steps:

  1. Add the following script as a custom code in Tag Manager. Don’t use the custom event tag.
    <script>
        _ppas.push(["trackEvent", "category", "action"]);
    </script>

To add a goal, follow these steps:

  1. Add this script as a custom code in Tag Manager. Don’t use the goal conversion tag.
    <script>
        _ppas.push(["trackGoal", goalID, conversionValue]);
    </script>

    Parameters

    goalID (number | string , required)
    The ID of the goal to be tracked. (To find a goal ID go to Menu > Analytics > Goals.)

    conversionValue (number, optional)
    The value of the goal. It’s used to calculate the goal revenue. 

Option #2: Use only Matomo tracking code, but modify it

Option #2 is usually a good idea if you want to send data from Matomo to our product, for example if you are considering switching from Matomo and want to do some testing. This way, you essentially track the site with only one source (Matomo tracker) and can make comparisons between Matomo reports and ours. The downside of this method is that you can’t use all Piwik PRO features.

To modify the Matomo tracking code, follow these steps:

  1. Find the Matomo tracking code in your Matomo account. (Where to find it?)

    Example:

    <!-- Matomo -->
    <script type="text/javascript">
        var _paq = window._paq = window._paq || [];
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function() {
            var u = "//{$MATOMO_URL}/";
            _paq.push(['setTrackerUrl', u + 'matomo.php']);
            _paq.push(['setSiteId', {
                $IDSITE
            }]);
            var d = document,
                g = d.createElement('script'),
                s = d.getElementsByTagName('script')[0];
            g.type = 'text/javascript';
            g.async = true;
            g.src = u + 'matomo.js';
            s.parentNode.insertBefore(g, s);
        })();
    </script>
    <!-- End Matomo Code -->
  2. Add this piece of code to the Matomo tracking code right after setSiteID:
    _paq.push(['addTracker', dataCollectionURL, siteIDinPiwikPRO]);

    Parameters

    dataCollectionURL
    Your Piwik PRO account URL, followed by ppms.php. Example: https://example.piwik.pro/ppms.php

    siteIDinPiwikPRO
    The ID of the site or app in Piwik PRO where you want to send data. (Where to find it?)

  3. Done! Now all of your events sent to Matomo will also be sent to Piwik PRO. Data will appear in reports in about an hour. Data in the tracker debugger will appear instantly.

    Note: Currently, you can track sites using the Matomo tracking code and send the collected data to Piwik PRO since we’re backwards compatible with Matomo. However, as both products continue to grow, there may be differences, and this method might no longer be effective.

Note: These methods are not yet compatible with our tracking libraries for React and Angular.

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