Skip to main content

Tracking Sign Ups with Auth0 and Cometly

Learn how to track sign ups in Cometly when using Auth0.

Updated over a week ago

Start Here 👋

If you're using Auth0 for user authentication and sign-ups, and you want to track those sign ups as events inside Cometly, this guide will walk you through how to do that properly.

Overview

To accurately attribute sign ups with Cometly, you need to:

  1. Install the Cometly Pixel on your website

  2. Capture the comet_token using the cometToken() function

  3. Pass the comet_token into your Auth0 sign up flow

  4. Send a webhook to Cometly with the user’s data


1. Install the Cometly Pixel

To begin tracking any activity on your site, the Cometly Pixel must be installed on all relevant pages. This includes the page where your Auth0 sign up button or flow is initiated.

SaaS Company Cometly Pixel Installation:
The Cometly Pixel should be installed on ALL marketing site pages, and ONLY on the app registration and app login pages. Do not install the Cometly Pixel across your entire SaaS application.

Follow this article to install the pixel:
➡️ How to Install & Verify the Cometly Pixel


2. Capture the comet_token

Once the pixel is installed, use the cometToken() function from the Cometly Pixel script to capture the unique tracking token associated with each website visitor.

const comet_token = cometToken();


Make sure to run this on the page where the sign up is triggered, and securely pass it through to your Auth0 sign up metadata.


3. Pass comet_token Into Auth0 Sign Ups

Depending on how you have Auth0 set up, you can include the comet_token in:

  • User metadata during a custom sign up process

  • A hidden field if using a custom sign up form

  • Redirect callback URLs or state parameters that persist the token through the flow

Here’s an example of attaching it to the sign up metadata in a custom sign up:

auth0.signup({ email: userEmail, password: userPassword, user_metadata: { comet_token: cometToken() } });

⚠️ Make sure this data is available in your backend or Auth0 webhook after sign up is completed.


4. Send a Webhook to Cometly

Once the user has successfully signed up and you have access to their email and comet_token (and optionally, first name and last name), send that data to a Cometly webhook.

Here’s an example JSON payload:

{ "event_name": "Sign Up", "comet_token": "123456abcdef", "email": "newuser@example.com", "first_name": "John", "last_name": "Doe" }


You can post this to the webhook URL you set up inside your Cometly account.



✅ You're Done!

Once implemented, all sign ups through Auth0 will be properly attributed and tracked inside Cometly.

Did this answer your question?