Skip to main content
When a visitor signs up through OAuth on your site (for example “Sign up with Google”, Microsoft or Apple), there is no form for the Cometly pixel to read. The pixel is the tracking script you install on your site, and it normally captures form fields like email, first name, last name and phone number automatically. To track OAuth sign-ups in Cometly, you send the event (the sign-up you want Cometly to record) yourself and include those details, plus the comet_token. The comet_token ties the event back to the visitor’s original journey. With it, each OAuth sign-up is linked to the ad or channel that brought the visitor in, so these sign-ups count in your reporting like the ones made through a form.
Sign-up buttons for Google, Microsoft and Apple, with an arrow pointing at Sign up with Google

Prerequisites

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 the cometToken() 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:
  1. Right-click on the page and select Inspect.
  2. Go to the Network tab.
  3. In the search bar, type comet.
  4. Look for Fetch/XHR requests, then click the init event in the list.
  5. Open the Payload section. The comet_token is included in the data.

Retrieve the comet_token in code

Call cometToken() from your site’s JavaScript. For example:
See Comet Token for more examples.

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:
For better attribution accuracy, also include first_name and last_name (or full_name). Example of a more detailed payload:
Alternatively, provide the full name in a single field:
For all event fields and advanced options, see Create Event and the API overview.

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. The cometToken() 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 include lead_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

Still have questions or need a hand? We’re happy to help. Reach our team at support@cometly.com.