Conversion tracking require a Business plan subscription or higher.
When it comes to conversion tracking, a lead event happens when a user performs an action that indicates interest in your product or service. This could be anything from:
  • Signing up for an account
  • Adding a product to cart
  • Joining a mailing list
A diagram showing how lead events are tracked in the conversion funnel
In this guide, we will be focusing on tracking new user sign-ups for a SaaS application that uses Google Tag Manager to track conversions.

Prerequisites

Before you get started, make sure you follow the Dub Conversions quickstart guide to get Dub Conversions set up for your links:
  1. Enable conversion tracking for your links
  2. Install the @dub/analytics client-side SDK via GTM

Configure Google Tag Manager server-side tracking

To track lead conversion events with Google Tag Manager, you’ll need to set up a server container and configure a custom client to handle Dub conversion events.

1. Set up GTM Server Container

In Google Tag Manager, you’ll need to use an existing server container or create a new one. Server containers are the foundation for server-side tracking and allow you to process events before they reach their final destinations.

2. Import Dub GTM Server Client Template

Inside your GTM server container, navigate to the Templates tab. Under Client Templates, click the New button.
GTM New Client Template
This will open up the Template Editor. In the top right corner, click on the button and select Import.
GTM Import Client Template
Download the gtm-server-client-template/template.tpl file and upload it to the Template Editor. You’ll see a preview of the template:
GTM Server Client Template
Click the Save button in the top right to save the template.

3. Create Dub Server Client

Next, you’d want to create a new GTM Server Client using the imported template. In your GTM server container, navigate to the Clients tab and click New.
GTM New Server Client
This will open up the client configuration page, where you can choose a client type to begin setup. Under Custom, select the Dub GTM Server Client template that you created in step 2.
GTM Choose Client Type
Make sure your client configuration is set to the following:
  • Client Name: Dub GTM Server Client
  • Priority: 0
  • Request Path: /dub/track
  • Debug Logging: (optional)
GTM Server Client
Clients in GTM Server are adapters that act as bridges between the software running on a user’s device and your server container. They receive requests and transform them into events that can be processed by tags.

4. Import Dub GTM Server Tag Template

Next, you’ll want to import the Dub GTM Server Tag template to handle lead tracking. In your GTM server container, navigate to the Templates tab once again. Under Tag Templates, click the New button.
GTM New Tag Template
This will open up the Template Editor. In the top right corner, click on the button and select Import.
GTM Import Client Template
Download the gtm-server-tag-template/template.tpl file and upload it to the Template Editor. You’ll see a preview of the template:
Dub GTM Server Tag Template
Click the Save button in the top right to save the template.

5. Add Lead Tracking Tag

Last but not least, you’ll want to create a new GTM Server Tag using the imported template. In your GTM server container, navigate to the Tags tab and click New.
GTM New Tag
This will open up the tag configuration page. Under Tag Configuration, select the Dub Conversion Tag server tag template that you created in step 4.
GTM Choose Tag Type
Make sure your tag configuration is set to the following:
  • Dub API Key: Your Dub API key (starts with dub_)
  • Event: Select “Track lead” from the dropdown
  • Click ID: clickId from the Dub Server Client event data
  • Customer External ID: customerExternalId from the event data
  • Event Name: eventName from the event data (e.g., “Sign Up”)
  • Customer Name: customerName from the event data
  • Customer Email: Map to the customerEmail from the event data
  • Customer Avatar: Map to the customerAvatar from the event data (optional)
  • Event Quantity: Map to the eventQuantity from the event data (default: 1)
GTM Lead Tracking Tag
Under the Triggering section, configure when the tag should fire:
  • Click + to add a new trigger
  • Select Custom Event as the trigger type
  • Set the Event Name to match the event name from the Dub Server Client. Default is dub_conversion
  • Add a condition to filter for lead events:
    • Variable: Select a variable that contains the event type
    • Operator: Equals
    • Value: “Sign Up”
  • Name the trigger “Dub Lead Event Trigger” and save it
Here’s the full list of attributes you can pass when sending a lead event:
PropertyRequiredDescription
clickIdYesThe unique dub_id parameter that the lead conversion event is attributed to.
eventNameYesThe name of the event. Example: “Sign up”.
customerExternalIdYesThe unique ID of the customer in your system. Will be used to identify and attribute all future events to this customer.
customerEmailNoThe email address of the customer. If not passed, a random email address will be generated.
customerNameNoThe name of the customer. If not passed, a random name will be generated (e.g. “Big Red Caribou”).
customerAvatarNoThe avatar URL of the customer. If not passed, a random avatar URL will be generated.

Testing your setup

You can test your GTM server setup by sending a curl request to your server URL with the appropriate query parameters:
curl "https://server-side-tagging-xxx-uc.a.run.app/dub/track/lead?\
dub_id=pAzVZ3jzwZXcLMDT&\
eventName=Sign%20Up&\
customerExternalId=user_1K0RN3SDNAC0C1WCW4BGRS3EW&\
customerName=John%20Doe&\
customerEmail=john@example.com&\
customerAvatar=https://example.com/avatar.jpg&\
eventQuantity=1&\
mode=async"

Download GTM templates

To learn more about how to track leads with Google Tag Manager, check out the following templates:

View your conversions

Once you’ve completed the setup, all your tracked conversions will show up in Dub Analytics. We provide 3 different views to help you understand your conversions:
Time-series line chart
  • Funnel chart: A funnel chart view visualizing the conversion & dropoff rates across the different steps in the conversion funnel (clicks → leads → sales).
Funnel chart view showing the conversion & dropoff rates from clicks → leads → sales
  • Real-time events stream: A real-time events stream of every single conversion event that occurs across all your links in your workspace.
The Events Stream dashboard on Dub