
Prerequisites
- The Cometly pixel is installed on the page that shows the OAuth buttons. See Install and verify the Cometly pixel.
- You can send events to Cometly from your own code, for example with the Create Event API endpoint.
What is the comet_token?
The comet_token is a unique identifier that links a visitor’s actions to their attribution journey in Cometly. Capture it at the moment the visitor clicks the OAuth button. You get it from thecometToken() function, which the Cometly pixel makes available on your site. The function returns the comet_token as a string, which you include in your event payload.
To check that the comet_token is being generated and sent, inspect your page with your browser’s developer tools:
- Right-click on the page and select Inspect.
- Go to the Network tab.
- In the search bar, type
comet. - Look for Fetch/XHR requests, then click the init event in the list.
- Open the Payload section. The comet_token is included in the data.
Retrieve the comet_token in code
CallcometToken() from your site’s JavaScript. For example:
Minimum required payload
You can send any event that makes sense for your workflow. For an OAuth sign-up, the payload must include at least the event_name, email and comet_token. Example of the minimum payload:Recommended payload
For better attribution accuracy, also include first_name and last_name (or full_name). Example of a more detailed payload:Check it worked
Complete a test sign-up with one of your OAuth buttons. Then go to Events Manager, click the Events Log tab and set Source to Server. Your event appears in the log, and its details show the email and comet_token you sent.Frequently asked questions
Can I send the OAuth sign-up event from my server instead of the browser?
Yes. ThecometToken() function only exists in the browser, where the Cometly pixel runs, so read the token there when the visitor clicks the OAuth button. Pass it to your backend (for example in a hidden field or a state parameter that survives the OAuth redirect), then include it as comet_token when your server sends the event.
What happens if I send the sign-up event without the comet_token?
Cometly still accepts an event that has an email address, because an email is enough to identify the person. The comet_token is what links the event to the visitor’s browser session, so leaving it out makes attribution less accurate.Which event name should I use for an OAuth sign-up?
Use the event that matches what the sign-up means for your business. The standard events includelead_generated, sign_up, complete_registration and start_trial, and you can also send a custom event you have configured. See Create Event for the full list.
Next steps
- Learn more ways to use the comet_token
- See every field the Create Event endpoint accepts
- Set up the Cometly pixel for a SaaS product
- Track sign-ups that go through Auth0
- Set up and test your events