Enriching Marketing Automation via Server-Side GTM and Firestore: The HBM Machines Case
While many industry experts discuss the advantages of using first-party data to enhance incoming events in Server-Side GTM, few companies fully leverage these benefits. When the opportunity arises, showcasing a hands-on approach can be invaluable. This case study explores how HBM Machines unlocks the potential of Server-Side GTM by enriching marketing automation with product data to make communications more relevant.
About the Customer
HBM Machines began as a small tool shop in Gouda over 50 years ago and has since grown into one of the most recognized suppliers of machinery, tools, and accessories. With over 9,000 products across seven categories—Workshop Equipment, Tools, Construction, Automotive, Metalworking, Woodworking, and Outdoor & Garden—HBM has expanded its online presence across multiple countries, including the Netherlands, Belgium, Germany, France, and Austria, with further expansion planned.
The Challenge
As with any online retail company, a big challenge for HBM is to build a strategy that allows for relevant communications with their customers and visitors. Specifically, they needed a solution to enable “abandoned cart” emails—a strategy where customers who view add items to their cart but don’t complete the purchase receive a reminder email.
Their email tool, Klaviyo, can trigger these reminders but has limitations: it can’t dynamically display specific product information from the product feed based on item IDs in cart events. Without this, the emails were generic, potentially reducing engagement. Rather than adding static product information, which is complex and error-prone, David Arnemann from HBM challenged us to explore an alternative—enriching Klaviyo events in Server-Side Google Tag Manager (GTM) with product data from Firestore.
The Solution in Detail
In HBM Machines’ setup, several foundational elements were already in place to support this solution.
Firstly, the product feed for various marketing channels was managed in Channable, an ideal setup for this use case. Channable made each feed available as a URL, allowing it to be accessed like any API. Secondly, Server-Side Google Tag Manager (SGTM) was already correctly configured with a basic setup, saving the time needed to build that infrastructure from scratch. Finally, HBM Machines had a Google Cloud environment with a ready-to-use base architecture, rounding out the essential tools for this project.
The first part of the solution operates within the Google Cloud Platform. Each day, API calls to Channable gather data feeds for all relevant HBM countries, transform them into the required format, and store them in a Firestore collection. Google Cloud Firestore, a no-SQL database optimized for rapid data read-and-write operations, proved to be a perfect fit. The API calls are facilitated through Google Cloud Functions, a cost-effective serverless platform that runs these tasks daily.
The second part of the implementation occurs in SGTM. When a product detail page (PDP) view, add-to-cart, or begin-checkout event is triggered, SGTM enriches the event with data from the Firestore collection. Using the product ID, SGTM retrieves details like the image URL, product URL, and description in the correct language for the specified country. This enriched information is then sent to Klaviyo’s backend API. Since some events contain multiple products, a standard Firestore connector was insufficient, so we implemented a custom solution.
Another challenge was retrieving the correct Klaviyo profile IDs. Since these IDs aren’t present on the website, we had to make an additional API call to translate the on-site identifier to the Klaviyo profile ID.
Both of these challenges were solved with a custom variable template in SGTM. This template, using a Promise setup, connects to both Firestore and Klaviyo, gathers the Profile ID and product information, and passes them along as the event enters SGTM.
Once all necessary information is collected, consent levels are checked and validated, the event is forwarded to Klaviyo, enabling it to trigger an abandoned browse or cart email with relevant product details displayed for each recipient.
The Solution in Broad Strokes
- Product Feed Management: Managed in Channable and accessible as a URL, simplifying data retrieval.
- Existing SGTM Setup: A foundational Server-Side GTM configuration was already in place.
- Google Cloud Platform & Firestore: Daily API calls gather data from Channable and store it in a Firestore collection, optimized for fast access.
- Event Enrichment in SGTM: Enriches each event with product details (e.g., image, URL, description) retrieved from Firestore using product IDs.
- Klaviyo Profile ID Retrieval: Custom API calls translate on-site identifiers into Klaviyo profile IDs for accurate email targeting.
- Custom Variable Template in SGTM: Connects to Firestore and Klaviyo, gathering necessary data using a Promise setup to handle multiple products in events.
Value for the Client
With the current setup, HBM Machines can provide more relevant communication to their in-journey clients, setting the stage for better-converting journeys and longer-term engagement with clients. HBM has the opportunity to further unlock first-party data use cases to increase customer relevance, and improve conversion rates and customer loyalty.
As HBM’s David Arnemann states, “This solution lets us maintain a simple event dataLayer, reducing the burden on our developers, and is easily extendable for future event enrichment in Server-Side GTM.”