BlueConic

BlueConic-OneSignal integration Overview

The BlueConic-OneSignal integration requires:

  • Syncing the OneSignal ID (known as ‘Player ID’ in OneSignal) to BlueConic
  • Syncing the BlueConic ID to OneSignal (as the ‘External User ID’ in OneSignal)
  • Passing BlueConic key value data over to OneSignal each time a user visits the site

The following code, delivered to all pages on a site via Google Tag Manager, enables all 3 of the steps above. It relies on the SDK libraries for OneSignal and BlueConic being in place on the site, but I’m told will work whether it is used with a ‘Typical Set Up’ or ‘Wordpress Set Up’.

<script>
function BC_OS_sync() {
    var profile = blueConicClient.profile.getProfile();

    OneSignal.push(function() {
        OneSignal.isPushNotificationsEnabled().then(function(notificationsEnabled) {
            OneSignal.getUserId().then(function(value) {
                console.log("OS User ID: ", value);
                console.log("BC User ID: ", profile.getId());
                profile.addValue("onesignal_user_ids", value);

                if (notificationsEnabled) {
                    profile.addValue("onesignal_user_ids_dates", new Date().getTime());
                }

                blueConicClient.profile.updateProfile();
                OneSignal.setExternalUserId(profile.getId());
            });
        });
    });
}
BC_OS_sync();
</script>

The code works in tandem with the setting up of a couple of items within BlueConic:

  • One to store the OneSignal ID/s belonging to subscribed users (if the profile property ID is to match with that in the script above, it would need to be titled: OneSignal_User IDs)

  • One to store the Timestamps of when users with OneSignal subscriptions in place visit the site (if the profile property ID is to match with that in the script above, it would need to be titled: OneSignal_User IDs_Dates)

Webhook export connections:

These use the OneSignal API to write key value data, for selected BlueConic profile properties or segments, into OneSignal against the specific BlueConic ID synced to the OneSignal platform as the ‘External User ID’. This data appears as “Tags” in OneSignal terminology.

Here is an example of a webhook export that supports sending Profile Property data from BlueConic to OneSignal as ‘Tags’. The red redaction is where the OneSignal APP ID for the site in question goes (this can be found for the App under ‘Settings’ in the One Signal UI). One of these needs to be set up per site, as an ‘Export Goal’ within a BlueConic webhook connection. This can then included all the profile property data wanted for that site. For each Profile Property at Stage 4 you specify the name you want the tag to have in OneSignal and match it to the actual name of the property in BlueConic, so that the values are populated. So, “name_in_OneSignal”: “{{name_of_property_in_BlueConic}}”

1758

Here is an example of a webhook export that supports sending Segment data from BlueConic to OneSignal. The red redaction is where the OneSignal APP ID for the site in question goes. For segment data, you need to create a separate ‘Export Goal’ in BlueConic per segment that you want to send. You add the segment ID you want to send to Step 1 and then, at Step 4, create a hard coded key value to represent inclusion in that segment, something like “Yes”. So, “name_in_OneSignal”: “Yes”

1767

Note 1: While ID syncing happens between the OneSignal and BlueConic platforms on the first page view, when the user subscribes to notifications via the OneSignal prompt, the user’s BlueConic profile property and segment data transfer does not start until a second page view happens. It is then refreshed on each subsequent visit.

Note 2: If the profile property data is stored in BlueConic as a list or array, this method will transfer the data to OneSignal, BUT in OneSignal any data involving multiple values cannot be parsed to create OneSignal segments for targeting (only single values are supported). To work around this, it is possible to create individual BlueConic segment/s from the values you are interested in and send each across to OneSignal using the segment transfer process above.