> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cometly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Track sign-ups made with OAuth (Sign up with Google)

> Track OAuth sign-ups in Cometly: send an event with the comet_token so sign-ups through Google, Microsoft or Apple are tied to the ad behind them.

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](https://mintcdn.com/cometly/BM7eSn6-ecx8ZzBx/images/guides/tracking/oauth-signups/01.webp?fit=max\&auto=format\&n=BM7eSn6-ecx8ZzBx\&q=85\&s=d0facad6867e068c77502d4c410cfaf1)

## Prerequisites

* The Cometly pixel is installed on the page that shows the OAuth buttons. See [Install and verify the Cometly pixel](https://docs.cometly.com/getting-started/install-pixel.md).
* You can send events to Cometly from your own code, for example with the [Create Event](https://docs.cometly.com/api-reference/endpoint/create-event.md) 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 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:

```javascript theme={null}
// Example: read the comet_token when the visitor clicks the OAuth button
const token = cometToken(); // returns the comet_token as a string
console.log(token); // include this value in your event payload
```

See [Comet Token](https://docs.cometly.com/concepts/comet-token.md) 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:

```json theme={null}
{
  "event_name": "lead_generated",
  "email": "developers@cometly.com",
  "comet_token": "ddffd8d8338383883838484843838388d8df8f"
}
```

## Recommended payload

For better attribution accuracy, also include **first\_name** and **last\_name** (or **full\_name**).

Example of a more detailed payload:

```json theme={null}
{
  "event_name": "lead_generated",
  "email": "developers@cometly.com",
  "comet_token": "ddffd8d8338383883838484843838388d8df8f",
  "first_name": "John",
  "last_name": "Smith"
}
```

Alternatively, provide the full name in a single field:

```json theme={null}
{
  "event_name": "lead_generated",
  "email": "developers@cometly.com",
  "comet_token": "ddffd8d8338383883838484843838388d8df8f",
  "full_name": "John Smith"
}
```

For all event fields and advanced options, see [Create Event](https://docs.cometly.com/api-reference/endpoint/create-event.md) and the [API overview](https://docs.cometly.com/api-reference/overview.md).

## Check it worked

Complete a test sign-up with one of your OAuth buttons. Then go to [**Events Manager**](https://app.cometly.com/space/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](https://docs.cometly.com/api-reference/endpoint/create-event.md) for the full list.

## Next steps

* [Learn more ways to use the comet\_token](https://docs.cometly.com/concepts/comet-token.md)
* [See every field the Create Event endpoint accepts](https://docs.cometly.com/api-reference/endpoint/create-event.md)
* [Set up the Cometly pixel for a SaaS product](https://docs.cometly.com/guides/tracking/pixel-setup-for-saas.md)
* [Track sign-ups that go through Auth0](https://docs.cometly.com/integrations/guides/auth0-sign-ups.md)
* [Set up and test your events](https://docs.cometly.com/getting-started/events.md)

Still have questions or need a hand? We're happy to help. Reach our team at [support@cometly.com](mailto:support@cometly.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.