Note: Cloudflare Apps are deprecated and will be discontinued after August 31, 2024.

Matomo users who relied on the Matomo app within Cloudflare, will need to implement an alternative method to ensure the Matomo tracking code is still added to their website.

This guide explains how to utilise Cloudflare Zaraz tools for Matomo tracking in Cloudflare. Zaraz is available to all Cloudflare users, including free plan subscriptions.

Set up Matomo with Zaraz

  1. Login to your Cloudflare account and from the dashboard, select the website where you want to set up Matomo tracking.

  2. Navigate to the Zaraz menu and select Tools Configuration.
    matomo cloudflare zaraz tool

  3. Choose the Custom HTML tool and step through the setup wizard to confirm adding the tool and enabling Grant permissions.

  4. Provide a meaningful Tool Name e.g., Matomo tracking and click Continue.

  5. You will be prompted to create a new action. Provide an Action Name e.g., ‘Inject Matomo tracker code’ or ‘Inject MTM script’ if you are using Matomo Tag Manager.

  6. Set the conditions for executing the script on each web page by choosing the Firing Triggers. If no custom triggers are configured, only the Pageview and All Tracks triggers are available for selection.

  7. Insert your Matomo tracking code in the HTML Code block and click Save.
    matomo cloudflare zaraz inject code

  8. Your configured action for the newly-added Custom HTML tool will be available in your Cloudflare > Zaraz > Tools Configuration. You can edit the tool configuration using the options for Settings, Permissions, Cookies, and creating new actions.

  9. To test the setup, perform user actions on your website and then login to your Matomo instance to check the Real-time Visits Report.

Enable History feature (optional)

Zaraz tools provide a History feature to help you keep track of changes made to the tool configurations.

  1. In the Zaraz menu, navigate to History (1) and toggle the Preview & Publish Workflow option to enable the feature.

  2. When Zaraz detects changes made to actions, triggers, and variables, it will display a button showing the number of changes that need to be published to the live environment (2).
    cloudflare zaraz history feature on

  3. Review the configuration changes in the list before publishing.

  4. You can revert to a previous configuration version by clicking Restore. Confirm your selection and proceed to publish.

By following this guide, you can successfully integrate Matomo with Cloudflare using the Zaraz tools. If you encounter any issues using Cloudflare or Zaraz, explore their online resources or reach out to their support teams for assistance.

Disclaimer: The use of any third-party tools (plugins, extensions, platforms, APIs, widgets, etc.) is at your own risk. Matomo does not own, control, maintain or support any third-party tools that integrate with our product. We recommend checking your privacy setup is correctly configured across your environment when using any third-party tools.