Track user activity on AuthKit pages in Google Analytics.
The Google Analytics AuthKit Add-on gives you data about logins, sign ups, and many other AuthKit activities inside of Google Analytics. You can use that data to better understand the effectiveness of your marketing campaigns and your users’ full journeys across your website and AuthKit.
To use the Add-on, your Authentication API Domain must share the same root as the domain where you set up Google Analytics through Google Tag Manager or gtag.js. This gives the Add-on access to your users’ Google Analytics client IDs, which the Add-on uses to associate events in AuthKit with users from your website.
For example, if your Google Analytics script lives at www.example.com:
In the WorkOS Dashboard, click the Authentication icon in the sidebar. Then click Add-ons.
Click Enable next to Google Analytics.
In another browser tab, visit Google Analytics to get your credentials. Click the Admin icon in the bottom left corner.
Under Data collection and modification, click Data streams.
Click the data stream that you used to set up Google Analytics on your website. Under Measurement ID, click the copy icon. Paste your Measurement ID in the Measurement ID field in the WorkOS Dashboard.
Under Events, click Measurement Protocol API secrets.
Click Create. Give your new secret a name, like WorkOS AuthKit Add-on. Copy the Secret value. The secret value may be cut off on narrower windows, so try double clicking the value before copying it to ensure you have selected the full value.
Paste the secret value in the API Secret field in the WorkOS Dashboard. Click Save changes. The Google Analytics AuthKit Add-on is enabled and will begin sending AuthKit events to Google Analytics.
The Add-on sends events to Google Analytics when certain WorkOS Events occur:
user.created
sends Google a sign_up
recommended eventauthentication.magic_auth_succeeded
, authentication.mfa_succeeded
, authentication.oauth_succeeded
, authentication.passkey_succeeded
, authentication.password_succeeded
, and authentication.sso_succeeded
send Google a login
recommended event including a method
parameter matching the login methodsession.created
send Google events based on the WorkOS event name, with underscores replacing periodsauthentication.email_verification_succeeded
is shortened to auth_email_verification_succeeded
to meet Google’s requirement that event names be 40 characters or shorterAfter enabling the Add-on, visit your website, click your sign in button, and sign in to your application. Visit Google Analytics and click Reports in the sidebar. Then click Realtime overview. Within five minutes, you should see a login
event under Event count by Event name.
If you do not see a login event, visit the Add-ons page in the WorkOS Dashboard to verify your Measurement ID and API Secret match the values from Google Analytics. If after confirming the values match you still need support, please reach out to us in Slack.