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 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.
  • If you already have a server container set up, you can use that
  • If not, create a new server container in your GTM workspace
2

Import Dub GTM Server Client Template

Add a new Client Template using the import option:
  1. In your server container, go to Client TemplatesNew
  2. Click Import and upload the Dub GTM Server Client template
GTM Server Client Template
3

Create Dub Server Client

Next, create a new Client using the imported template:
  1. In your server container, go to ClientsNew
  2. Select the Dub GTM Server Client template from Custom
  3. Name the client “Dub Server Client” (or any descriptive name)
  4. Set the Request Path to /dub/track
  5. Optionally enable debug logging for troubleshooting
GTM Server Client
Note: 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, import the Dub GTM Server Tag template to handle lead tracking:
  1. In your server container, go to TagsNew
  2. Click Import and upload the Dub GTM Server Tag template
  3. This template is specifically designed to send conversion events directly to Dub
Dub GTM Server Tag Template
5

Add Lead Tracking Tag

Next, create a new tag for lead tracking with proper mapping:
  1. In your server container, go to TagsNew
  2. Select the Dub Conversion Tag template from Custom
  3. Name the tag “Dub Lead Tracking” (or any descriptive name)
  4. Configure the tag settings:
    • Dub API Key: Enter your Dub API key (starts with dub_)
    • Event: Select “Track lead”
    • Click ID: Map to the clickId from the Dub Server Client event data
    • Customer External ID: Map to the customerExternalId from the event data
    • Event Name: Map to the eventName from the event data (e.g., “Sign Up”)
    • Customer Name: Map to the 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)
    • Mode: Set to “async” for non-blocking requests
  5. Triggering: Configure when the tag should fire:
    • Click Triggering in the tag configuration
    • 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
GTM Lead Tracking Tag
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