Skip to content

Connect HubSpot and OneSignal

Last updated: September 4, 2023

Available with any of the following subscriptions, except where noted:

Marketing Hub   Professional , Enterprise
Sales Hub   Professional , Enterprise
Service Hub   Professional , Enterprise
Operations Hub   Professional , Enterprise

With the OneSignal integration, you can create and send OneSignal push notifications using workflows, view push notifications on contacts' activity timelines, and segment users based on engagement with push notifications

Integration requirements

Connect the app

  • In your HubSpot account, click the Marketplace icon marketplace in the top navigation bar, then select App Marketplace.
  • Use the search bar to locate and select the OneSignal integration.
  • In the upper right, click Install app.
  • Log in to your OneSignal account.
  • In the pop-up box, enter your Application ID and API key from your OneSignal account.
  • If needed, click Add application to add another application.
  • Click Install app.
  • You will be redirected to the Connected apps page.

Match your OneSignal user to your HubSpot user

The integration requires matching your OneSignal user to HubSpot contacts. Users have two options for matching:

  • By email address: users need to use OneSignal's setEmail function using their SDK to associate OneSignal users with email addresses. This matching option is only available for the Send OneSignal notification workflow action.
  • By OneSignal external_user_id: users will need to select the HubSpot contact property they want to match with the external_user_id in OneSignal. To do so:
    • In your HubSpot account, navigate to Data Management > Integrations.
    • Click OneSignal.
    • Click Contact Matching.
    • From the dropdown menu, select the HubSpot contact property you want to use for matching with the OneSignal external_user_id property. This matching option is available for both the Send OneSignal notifications and Edit OneSignal tags workflow actions.

Automate OneSignal push notifications

You can automate sending OneSignal push notifications using workflows.

  • In your HubSpot account, navigate to Automations > Workflows.
  • In the top right, click Create workflow.
  • In the left panel, select Contact-based and click Next in the top right.
  • Set your enrollment triggers.
  • Click the + plus icon to add an action.
  • In the right panel, select Send OneSignal notification.
onesignal-notification

The push notification will appear as an activity on the contact record's timeline. 
 
onesignal-timeline


Automate OneSignal tags to trigger in-app messaging

Use workflows to trigger in-app messaging in your OneSignal app. 

  • In your HubSpot account, navigate to Automations > Workflows.
  • In the top right, click Create workflow.
  • In the left panel, select Contact-based, then click Next in the top right.
  • Set your enrollment triggers.
  • Click the plus icon to add an action.
  • In the right panel, select Edit OneSignal tags
onesignal-tags
  • Click the Select App dropdown menus to select your connected OneSignal apps.
  • Enter JSON string with { “key” : “value” } pairs you wish to edit. Learn more about using OneSignal data tags.
  • Click Save.
  • You can add additional actions to your workflow.
  • When you're finished setting up your workflow, click Review in the top right.
  • Review your workflow set up and click Turn on.

Editing OneSignal tags can also power in-app messaging in OneSignal. Refer to OneSignal's guide for steps on how to do so. 

Use HubSpot form submissions to link HubSpot contacts to OneSignal users 

To use this functionality, ensure that you have the appropriate code from your OneSignal Web Push settings added to the head HTML of your pages. 

You have two options for capturing and passing email addresses to OneSignal:

  1. Place the following globally in your <head> … </head> to apply across form submissions:

window.addEventListener('message', event => {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
OneSignal.push(function() {
OneSignal.setEmail($("input[name=email]").val())
.then(function(emailId) {
// Callback called when email have finished sending
console.log("emailId: ", emailId);
});
}
});

  1. Edit the embed script for one of your HubSpot Forms directly. You will need to insert your portal ID and form ID from your account. Here's an example:

    <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
    <script>
    hbspt.forms.create({
    region: "na1",
    portalId: "YOUR PORTAL ID",
    formId: "YOUR FORM ID",
    onFormSubmit: function($form) {
    OneSignal.push(function() {
    OneSignal.setEmail($("input[name=email]").val())
    .then(function(emailId) {
    // Callback called when email have finished sending
    console.log("emailId: ", emailId);
    });
    });
    }
    });
    </script>
Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.