Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

Enable Google Analytics for Clerk

This integration enables Clerk to send user authentication events to the configured Google Analytics property which corresponds to your application.

The Google Analytics integration can be enabled only for Production Instances.

To enable the integration, you will need to provide Clerk with the required Google Analytics configuration attributes depending on the type of Google Analytics property. We support both Universal Analytics and Google Analytics 4 properties.

To get started, go to the Clerk Dashboard and navigate to the Integrations(opens in a new tab) page. Turn on the Google Analytics integration.

The Integrations page in the Clerk Dashboard. A red arrow points to the toggle next to 'Google Analytics'.

Once enabled, you will be presented with a form to enter the required Google Analytics configuration attributes.

The Google Analytics configuration form in the Clerk Dashboard.

Configuration

To allow Clerk to report selected events on your Google Analytics property and improve your user analytics quality, you will need to set some configuration attributes on the integration page.

Integration type

To send events to Google Analytics servers, Clerk uses the Measurement Protocol(opens in a new tab) specification. Depending on your property type, you would need to provide the keys as described below:

Google Analytics 4

  • API Secret: An API secret generated in the Google Analytics UI. To create a new secret, navigate to Admin → Data Streams → choose your stream → Measurement Protocol → Create.
A gif showing how to access the API secret in the Google Analytics UI.
  • Measurement ID: The measurement ID associated with the data stream sending data to your Google Analytics 4 property. The format is G-XXXXXXX and can be found in the Google Analytics UI under Admin → Data Streams → choose your stream → Measurement ID.
A gif showing how to access the measurement ID in the Google Analytics UI.

Universal Analytics

  • Tracking ID: The tracking ID is a string composed of your account number and the property index and is used to send data to the correct Google Analytics property. The format is UA-YYYYYY-Z and can be found in the Google Analytics UI under Admin → Tracking Info → Tracking Code.
A gif showing how to access the measurement ID in the Google Analytics UI.

Include Clerk user ID

Since Clerk is used for the user management and authentication in your application, we provide the capability to associate the user identifier (UID) generated from Clerk with the User ID feature in Google Analytics. Enabling this feature will allow enhanced user analysis capablities on Google Analytics like cross-device user tracking, session unification and more.Read more about the User ID feature:

Google Analytics 4 User-ID(opens in a new tab)

Universal Analytics User-ID(opens in a new tab)

Events to track

Select during which user authentication events, such as user sign-in or user sign-up, a Google Analytics event should be recorded.

Sign-up

Sent every time a user signs up for your application through Clerk.

For Universal Analytics properties, this is sent as a custom event. The custom event is composed as:

  • Category: Clerk
  • Action: sign_up
  • Label: {{signup method}}

For Google Analytics 4 properties, this matches the standard sign_up event(opens in a new tab).

Sign-in

Sent every time a user signs in to his account through Clerk.

For Universal Analytics properties, this is sent as a custom event.

  • Category: Clerk
  • Action: login
  • Label: {{login method}}

For Google Analytics 4 properties, this matches the standard login event(opens in a new tab).

Frequently asked questions (FAQ)

Will Clerk events disrupt session attribution, user count or other metrics?

No, Clerk's production architecture allows us to configure the measurement protocol events sent to your property in such a way that session attribution, user count and identification attributes are kept intact.

What did you think of this content?

Clerk © 2024