Dynamic data collection with Zaraz Worker Variables
Jun 2, 2023Tom Klein, Lucas Kostka

Summary
Introduces Cloudflare Zaraz Worker Variables, a new capability that allows custom JavaScript code to be executed server-side within Cloudflare Workers. This enables dynamic data collection, cleaning, transformation, and enrichment for third-party analytics tools, mirroring functionality previously only available client-side with systems like Google Tag Manager's Custom JavaScript variables. The implementation uses Dynamic Dispatch to call user-defined Workers from the Zaraz Worker, providing context from the Zaraz session and system, and returning results as a Response object. Benefits include improved performance by avoiding client-side roundtrips, isolated execution environments, and secure handling of API secrets.