Setup your OneSignal app
Follow our Web push setup docs. When prompted, note your App ID, which you will replace in the code below.Copy & update the OneSignal initialization code
When you get to the step Add Code to Site click Copy Code.
Copy the code provided in your OneSignal dashboard.
Setup Google Tag Manager
Login to your Google Tag Manager Account and setup a new tag called OneSignal Init. The Tag Configuration/Tag Type should be Custom HTML. Paste the OneSignal code into the HTML field. Under Advanced Settings > Tag firing options select Once per page.

Refer to Google Tag Manager Help if you need additional setup assistance.
Testing
Visit your website and you should be prompted to subscribe to push notifications based on the prompt settings you setup. See Web permission prompts for details. Check your OneSignal Dashboard Audience > Subscriptions to see your Subscriptions. Find your subscription and set it as a Test subscriptions. Then head over to Messages > New Push to send yourself a notification.If running into issues, checkout the Web Push Troubleshooting Guide for common fixes.
Visit Web Push Tutorials for next steps or continue below for other GTM options.
Add data tags
This step sends custom User Data Tags (attributes) to OneSignal from GTM using theOneSignal.User.addTags
method.
Use the following code snippet to set tags. Replace "TAG_1"
and "VALUE_1"
with your desired tag key and value:
Create a trigger group for firing the tag
Create a trigger group for firing the tag
To ensure the tag fires under the proper conditions, configure a Trigger Group that combines:
- Trigger 1: A Custom Event trigger that fires on the event OneSignalInitialized (ensuring OneSignal has been initialized).
- Trigger 2: The additional trigger you want to use (for example, a page view or a custom user event).
- In your GTM Workspace, go to Triggers and click New.
- Select Trigger Group as the trigger type.
- Name the trigger group (e.g., “OS Tag – Initialized & Custom Trigger”).
-
Under Configure Trigger Group, add the following triggers:
-
Custom Event Trigger:
- Choose Custom Event as the trigger type.
- Set the event name to
OneSignalInitialized
.
-
Additional Trigger:
- Select the trigger that meets your criteria (e.g., All Pages, or a custom trigger such as after user login).
-
Custom Event Trigger:
- Save the Trigger Group.
Create the GTM tag for adding user profile tags
Create the GTM tag for adding user profile tags
Publish the changes
After configuring the new tag and its trigger group, publish your container to deploy the new user tagging functionality.Troubleshooting
Use GTM’s Preview and Debug Mode to ensure that both the initialization tag and the user profile tagging tag fire correctly. Check the browser console for any OneSignal-related errors and review your OneSignal Dashboard for error notifications. DataLayer Events: Confirm that the events (e.g., OneSignalInitialized) are pushed into the dataLayer as expected for further tracking in your analytics setup. See Web SDK troubleshooting for more details.With these updates, your website now uses the latest OneSignal initialization and sends custom user profile tags via GTM using the
OneSignal.User.addTags
method.The added trigger group ensures that the tag fires only after OneSignal has initialized and when your chosen conditions are met.