How do I install the Matomo tracking code on my Cloudflare setup
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
-
Login to your Cloudflare account and from the dashboard, select the website where you want to set up Matomo tracking.
-
Navigate to the Zaraz menu and select Tools Configuration.
-
Choose the Custom HTML tool and step through the setup wizard to confirm adding the tool and enabling Grant permissions.
-
Provide a meaningful Tool Name e.g., Matomo tracking and click Continue.
-
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.
-
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.
-
Insert your Matomo tracking code in the HTML Code block and click Save.
-
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.
-
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.
-
In the Zaraz menu, navigate to History (1) and toggle the Preview & Publish Workflow option to enable the feature.
-
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).
-
Review the configuration changes in the list before publishing.
-
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.