As a marketer, I have been inundated with articles explaining the importance of server-side tracking and first-party cookies since iOS 14.5+. However, my biggest gripe with it all was that I couldn't find an easy solution to the problem for smaller businesses. It feels like the main three options, for the last couple of years, have been:

  • A CDP
  • Manual code
  • Server-side GTM (Google Tag Manager)

For the last couple of years, the most accessible solution has been Server GTM. While many great content creators, like Simo A Hava, have put out amazing guides to make understanding server GTM easier  - I still feel like it's a huge technical leap from clientside GTM. 

Here are the biggest problems I find with Server GTM for smaller businesses:

  • Requires hosting on Google Cloud or AWS
  • Unpredictable costs compared to SaaS tools since it relies on DevOps
  • Data needs to be routed through GA4, which can introduce privacy concerns.
  • The concept is really technical and foreign to a lot of people, especially when compared to tag manager.

With all these problems, I found it hard to believe Server GTM will remaind the best solution for small businesses. 

Enter Cloudflare! Let's meet their new product, Cloudflare Zaraz.

Meet Zaraz

Cloudflare Zaraz is a relatively new tag management tool, that prides itself on hassle-free server-side tag management. While I don't think it's a full-fledged CDP replacement, this is a great option for businesses that want to improve their tracking. 

I believe Zaraz can replace Server GTM for many small businesses.  There are many reasons, but here are a few of them:

Easy installation

Getting started with Zaraz is extremely easy compared to server tag manager. Here are all the things you don't have to do with Zaraz:

  1. Set up a GA4 instance or another client to route your data through.
  2. Set up a Google Cloud or AWS server.
  3. Learn a complicated structure for your tags; feels very familiar to clientside Google Tag Manager.
  4. Install a script if you have Cloudflare as your CDN (content delivery network); it auto-injects itself.
  5. Write any code to send events if your site has dataLayer (GTM) events.

This means you could get started tracking by enabling Zaraz in settings without needing to write a single line of code.

Prebuilt compliance features

If you need to comply with privacy regulations, but can't afford expensive cookie management software, Zaraz literally comes with its own optional consent modal. From within these settings, you can:

  • Write your consent modal text in plain text, or customize it with HTML/CSS
  • Assign purposes for different kinds of tools (e.g. marketing v. functional)
  • Assign the aforementioned purposes to tools.

Zaraz also stores data separately on EU servers to be fully GDPR compliant. 

Built-in connectors 

While I think GTM's community templates are great, I admire that Zaraz is supporting a lot of destinations with prebuilt connectors. I actually prefer how easy it is to setup with Zaraz compared to server tag manager.

Generous Free Limit

Unlike Server Tag Manager, which will cost money to host on Google Cloud, Cloudflare Zaraz is free for up to 100K monthly pageviews. After that, it becomes akin to ‘Cloudflare Workers’ pricing – making it extremely affordable and a great solution for websites that receive less traffic.

Installation steps

Full documentation here.

Requirements:

  • A Cloudflare account 
  • Access to website code
  • GTM installed w/ dataLayer code (optional)
  • Access to DNS (optional)

1.  Provision a Cloudflare Account

If you already have Cloudflare as your DNS & CDN, you can skip directly to the next step.  Otherwise, you'll need to set up an account because Zaraz requires at least one domain proxied (orange cloud) via Cloudflare. I recommend using Cloudflare fully as your DNS / CDN; the installation is much easier this way. However, this ultimately depends on whether it makes sense for your website build. There are a few alternate paths below.

Alternate Setup - Proxy Only

 If you want to keep your current DNS but use Cloudflare as a proxy, here's a link with steps to do that. 

Alternate Setup - Subdomain Installation

If you don't want to proxy your main domain through Cloudflare, it can be configured on a subdomain. You'll ultimately need to install the Zaraz script manually instead of Cloudflare auto-injecting it. The format would look like this:

<script src="https://{your-subdomain}/cdn-cgi/zaraz/i.js"></script>

and it would go right before the closing  </head> tag of your website. 

If you choose to rename the Javascript file in step 2, you would also change the path in the URL of the script.

2. Configure Zaraz in the settings

Once you're in Cloudflare, you can find Zaraz in the settings under your website name. Reference the screenshot below:

Where to find Zaraz settings in the Cloudflare Panel

 Here is a quick rundown of the settings so you can customize it to your needs:

  • Workflow type - Whether changes go live immediately when you make them.
    • This requires a paid plan to switch to “preview mode.”
    • A good workaround is creating a rule in Cloudflare only to enable Zaraz on a staging/preview website until you're ready to deploy it. You can turn the rule off when ready to move it to production. 
  • E-commerce tracking - If you want to enable eCommerce tracking. 
    • This is essentially just a quality-of-life feature to make eCommerce events written with Zaraz's schema automatically translate to tools like GA4 and Meta Pixel. 
    • Not necessary for enabling eCommerce tracking, though; saves time on adding fields to your destination.
    • It is not compatible with dataLayer mode, so you can't use this feature if you go with that installation route. 
  • Data layer compatibility mode:  
    • If you have GTM installed, enable this and move to step 3A to make setting up events easier. 
    • If you haven't installed GTM or want to write the Zaraz code manually, leave this unchecked and move to step 3B.
  • Single Page Application support: If you have a SPA (e.g., Next.js) and want to track pageviews automatically. Similar to the history changes in Google Tag Manager.
  • Privacy: Optional ways to secure user privacy; such as trimming IP addresses or cleaning user agent strings.
  • Auto-inject script: Uncheck this to install the script manually; I don't recommend doing this unless you're installing Zaraz on a subdomain.
  • Iframe Injection: Whether you want also to track within iFrame elements; think Calendly embeds, for example. I'd recommend leaving this blank unless you know what you're doing.
  • Endpoints: Options to rename the javascript files. This is highly recommended because it makes it more resilient to ad blockers. 

3A. Configure Zaraz Using Existing GTM Code

I recommend using this as an easy way to get started with Zaraz. If your dataLayer code is written properly, it'll automatically capture those events in Zaraz. This means not needing to write any code unless there are additional events you want to configure. Eventually, I recommend implementing Zaraz code because you'll get access to cool features like the .set() function.

That's it; you can skip directly to step 4 without writing code. 

3B. Configuring Zaraz Manually.

If you write your own Zaraz code, the schema is relatively easy to apply - it's very familiar to GTM's dataLayer or Segment's analytics SDK. You have 2 types of events:

Track Functions

This is the main function you'll be using with Zaraz. The schema looks like this: 

zaraz.track(eventName, [eventProperties])

For a simple example, let's say you want to track a CTA button in the header; here's what the script would look like:

<script> 
async function ctaClick() {
	zaraz.track("cta-click",{ location: "header" });
};
</script>
[...]
<button id="cta" onclick="ctaClick()"</>

This would fire an event in Zaraz called “cta-click”; it has a property called location that tells us where the button is (in our example, the header of the website).

Set Functions

This is a really cool feature that I hope comes to Google Tag Manager. The set function allows you to set properties on the user level, rather than for each event. This is useful when you want data to be passed with multiple events or want something (like a user-id) to persist across multiple website sessions. Here's what the schema for this event looks like:

zaraz.set(propertyName, value)

The property name would be the name of the property you want to set for the user (e.g. “user-id”) and the value would be the data you're assigning to that property (e.g. “ID-547”). 

zaraz.set(propertyName, value)

You can also control how long the data persists by adding a scope; by default, the data is saved in local storage and will persist across sessions. However, let's say you only want to set this property for a specific page ('page') or a single session ('session'). Here's an example of how to do that:

zaraz.set('product_name', 't-shirt', {scope: 'page'})

Here's an example of how I used the set function to manually generate an ‘fbc’ parameter to pass to the Facebook Pixel. Because Zaraz will, by default, store this value across sessions, it should be the equivalent of Meta storing an ‘fbc’ parameter as a cookie. This script pulls the value from the URL, and then generates it in the format Meta expects it in:

<script>
let fbc = '';
const params = new URLSearchParams(document.location.search);
let fbclid = params.get("fbclid");
if (fbclid) {
   let currentTime = Date.now();
   let unixTime = Math.floor(currenttime);
   fbc = `fb.1.${unixTime}.${fbclid}`;
   zaraz.set("fbc",fbc);
}
async function 
</script>

Testing

Once you've implemented your events, you can utilize Zaraz's debugging features (documentation here) to test and ensure everything is passed properly.

3C. Using Zaraz's Built-in Triggers

Zaraz, similar to GTM, has a way to create triggers for events as well as variables. While I generally don't recommend this, you can also skip the code route completely and use Triggers to define elements. For example, you could create a trigger that only captures data from a form with the ID ‘contact’ like this:

An example of a form submission trigger in Cloudflare Zaraz

You can then try to get more data, such as the email in a form submission, by defining a variable in the Zaraz dashboard.

I don't recommend this as your only source of tracking because it'll be finicky with tech updates (e.g. a form id being changed) and you won't be able to pass more complex payloads (e.g. eCommerce data). 

4. Setup your first connector and test it.

After setting up your events, you can finally start sending some data to your third-party tools. You'll first want to set up triggers and variables (similar to how you would in Tag Manager). Once you're done, you can click “Add new tools” under Third-party tools in Zaraz.

A screenshot of where the add new tool button is located in Zaraz.

Click on the tool you want to set up, in our case Facebook pixel, and start adding the parameters you want. 

The setup Facebook Pixel tab of Cloudflare Zaraz

After that, hit save, and you're done!

Future Room for Improvements

While I think this tool is cool, I wouldn't eliminate Google Tag Manager just yet. There are a ton of quality-of-life improvements that need to be made to the tool, I believe, some of which include the following:

  • An easy-to-access community template library
  • A duplicate button for copying tags and triggers (seriously, adding fields 1 by 1 is painful).
  • Server templates for more vendors
    • Only some main vendors (Google, Meta, TikTok) are server-side. Most templates will fire on your website (like client-side GTM) rather than on a server. 
    • You can still send server traffic to these templates, but you'd need to use an HTTP request tag or web components.
  • Option for npm installation instead of auto-inject or script tag installation.
  • Better documentation and community support

Nothing here is a dealbreaker for me, but I believe these quality-of-life issues have prevented it from being widely adopted. Nevertheless, I have switched most of my clients to Zaraz. 

Conclusion

I really wanted to show this tool off because it breaks a giant barrier of difficulty for enabling server-side tracking. You can start without writing additional code if you already have Cloudflare as your CDN and have GTM installed. I have more content I'm putting out in the future covering more advanced topics of what you can do with Zaraz. If you don't want to miss it, sign up for my newsletter below.