Analytics with Cloudflare Zaraz: One Tool, Maximum Performance
Learn how Cloudflare Zaraz helps you manage analytics tools from one place, simplify cookie consent, and improve performance.
While developing a web and mobile game project, we needed an analytics tool. We started with Google Analytics, but soon needed Facebook Pixel as well. As the number of analytics tools grew, we began looking for a way to manage them through a single layer and found that Cloudflare Zaraz could solve that problem. First, let's look at what Cloudflare Zaraz is.
What is Cloudflare Zaraz?
"Zaraz increases web application speed, security, and privacy by loading third-party tools in the cloud, away from browsers. Load analytics tools, advertising pixels, widgets, and other third-party tools without slowing down your applications." That is how Cloudflare describes it on its website. Let's break this down.
The key idea is that you send analytics data to Cloudflare Zaraz, and Zaraz forwards that data to third-party tools on your behalf. Instead of loading every third-party script directly in the browser, you benefit from Cloudflare's infrastructure for speed, privacy, and security. Now let's look at why that matters.
Why Cloudflare Zaraz?
Ad Blocker Compatibility
With a traditional setup, many analytics and advertising tools may stop working when users have ad blockers enabled. Ad blockers often block these scripts automatically. With Cloudflare, the loading paths can run through your own domain, which gives you a better chance of avoiding those interruptions.
Performance
When you add multiple tools to your web application in the usual way, each one sends its own requests and adds overhead. That can hurt performance, especially when the same event needs to be sent to several destinations. With Cloudflare Zaraz, you send the event to Cloudflare once, and Cloudflare forwards it to the third-party tools you choose. You can then control which event goes where from the Cloudflare dashboard.
Cookie Consent Management
If you are launching a website for users in the European Union, you need to manage cookie consent properly. Doing this separately for every tool can become messy. With Cloudflare Zaraz, you can manage cookie consent from one place, which improves both the user experience and performance. The main downside is that the default styling is fairly standard and can be difficult to customize.
You can configure the necessary options from the Consent menu in the dashboard. This helps you meet both European consent requirements and Google Analytics consent expectations.
Usage
After you set it up in the Cloudflare dashboard, Zaraz becomes active on your site automatically if you are using Cloudflare DNS. You do not need any additional installation on the site itself.
If you want to send events yourself, you can use the zaraz.track function. For example:
zaraz.track("eventName", {
eventProperty1: "eventValue1",
eventProperty2: "eventValue2",
});
Then define a trigger in the dashboard: Create Trigger -> Event -> eventName. After the trigger is created, select the tool you want to send the event to, create an action, give the action a name, and choose the trigger that should fire it. Finally, select the event and save the configuration.
If you were already using gtag, you can continue without changing your existing implementation. You only need to enable the relevant setting.
If you want to identify a user, you can use the zaraz.set function. For example:
zaraz.set("userId", "12345");
If you run an e-commerce site, you can use the zaraz.ecommerce function. For example:
zaraz.ecommerce("purchase", {
transaction_id: "12345",
value: 100,
currency: "USD",
});
The difference is that this data is sent to Google Analytics automatically, without requiring extra work from you. For other event types, you need to define a trigger.
In short, you first define the event as a trigger, then use an action to send it to the tool you want.
To see what data is flowing from the events you defined, check the Monitoring section in the dashboard. You can view data from the last 72 hours. This section is useful for quick verification, but beyond event counts it does not offer much additional functionality.
Conclusion
Cloudflare Zaraz makes it easier to manage the analytics tools you need for a web or mobile game project from a single platform. By moving third-party tool handling into the cloud, it provides meaningful benefits for performance and security. Better ad blocker compatibility, lower performance overhead, and centralized cookie consent management are the features that make Zaraz especially useful.
Zaraz also gives you enough flexibility to route analytics data to different tools quickly and securely. For projects that target users in Europe, having a centralized consent flow can also make compliance work easier.
The simple setup and straightforward API are strong reasons to consider it. With zaraz.track, zaraz.set, and zaraz.ecommerce, you can track custom events, identify users, and monitor e-commerce transactions while sending the data to the right destinations.
In summary, Cloudflare Zaraz is a practical tool for analytics and performance needs in game projects. It improves the user experience, simplifies development work, and helps you manage analytics more efficiently from one place.