Integrations

Connect and use OneSignal Integration (BETA)

Last updated: April 12, 2021

In Beta

Applies to:

All products and plans

Connect your OneSignal account to HubSpot to set up 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 Integration

  • In your HubSpot account, click the Marketplace icon marketplace in the main navigation bar. Under Manage, select Connected apps.
  • In the upper right, click Visit App Marketplace.
  • Use the search bar to search for the OneSignal integration. Hover over it and click View integration.
  • In the top right, click Connect app.
  • Login to your OneSignal account.
  • In the pop-up box, enter your Application ID and API key from your OneSignal account. You can enter multiple IDs and keys in order to connect more than one OneSignal application.
  • Click Install app.
  • You will be redirected to the Connected apps page.

Use the Integration

You can use the One Signal integration to create and send OneSignal push notifications using Workflows, view push notifications on contacts' activity timelines, and segment users based on engagement with push notifications.

  • In your HubSpot account, click the Marketplace icon marketplace in the main navigation bar. Under Manage, select Connected apps.
  • Click OneSignal.
  • Click Actions on the selected OneSignal app to add additional apps or remove apps.
Please note: for your OneSignal users to receive push notifications, you need to use the OneSignal setEmail SDK Method. You can only associate one of either web or mobile push record, determined by where the setEmail method was executed last. Users must still subscribe to your site or app to receive push notifications. Please review OneSignal’s SDK documentation.

Create OneSignal push notifications (MarketingHub, SalesHub and ServiceHub Professional and Enterprise only)

  • In your HubSpot account, navigate to Automation > 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 + to add an action.
  • In the right panel, select Send OneSignal notification.

View push notifications on activity timeline

  • In your HubSpot account, navigate to Contacts > Contacts.
  • Click the name of a contact you've sent a push notification to.
  • On the activity timeline, you can view the OneSignal activity.

onesignal-timeline

Use HubSpot form submissions to link HubSpot contacts to OneSignal users 

To use this functionality, You need to make sure you have the appropriate code in <head> from your OneSignal Web Push Settings.

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. 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: "12345",
    formId: "3f9b1c13-16c2-444d-a24a-6331877102b4",
    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>