Manually Triggering the Opt-In Prompt

You may choose to disable automatic triggering of the opt-in prompt via the platform. In this scenario you would choose to trigger the prompt based on your own criteria (eg: after a visitor clicks a specific link, visits a specific page, etc).

Triggering the prompt is as easy as calling the show_prompt event when a visitor performs the desired action.

pushly('show_prompt', { checkEligibility: true })

If you want the prompt to show regardless of current subscription status or frequency capping (i.e., manually displaying a bell or custom prompt) this can be simplified to the following code.


Adding Attributes to a Subscriber's Profile

You can add attributes to a subscriber's profile and later perform segmentation based on those attributes. For example, you may want to tag visitors who are interested in a specific type of news (eg: politics, sports) so that you can target them with specific notifications.

pushly('profile', {
'is_paying_subscriber': true,
'interests': ['poltics', 'news']

Property values can be scalar or an array of scalar values.

If you're storing the value of a property as an array you can use the profile_append and profile_remove methods to add or remove values.

// add 'sports' to the subscriber's interests
pushly('profile_append', {
'interests': ['sports']
// remove 'fashion' and 'news' from the subscriber's interests
pushly('profile_remove', {
'interests': ['fashion', 'news']

Adding Page Keywords / Tags to a Subscriber's Profile

You can add page keywords / tags to a subscribers profile for every page they visit. These tags can then be used in segmentation to create cohorts of subscribers that have visited tags based on number of times and recency. For example: "Subscribers who have visited a page tagged with "Astrology" at least 4 times in the last 30 days".

pushly('page_tag_visit', ['Tag1', 'Tag2', 'Tag3']);

Setting the Subscriber's External ID

Providing a unique User ID for your subscriber allows you to later interact with that subscriber via the API.

There are two ways to provide the external ID:

On SDK Init

Preferably you may provide the external ID when the SDK is initialized. This requires adding one additional line of code to the load function. Note the new externalId line in the below script:

<script src="" async></script>
var PushlySDK = window.PushlySDK || [];
function pushly() { PushlySDK.push(arguments) }
pushly('load', {
domainKey: 'DOMAIN_KEY',

Via a separate method call

Alternatively you may provide the external ID any time after the SDK has loaded via the following code:

pushly('profile', {'external_id': 'h7bwKwuE3'});

You may combine the external_id profile call with any other profile information in to a single profile call.

Once a subscriber's external ID has been set you may work with our team to set up bi-directional automated data syncs. The following use cases are common ways that publishers use the external ID via server-to-server requests:

  • Sending notifications to individual subscribers programmatically

  • Processing unsubscribe requests

  • Adding and removing profile attributes and events to subscribers

Determining if a Visitor is Already Subscribed

If you need to know if a visitor is already subscribed to push notifications the following javascript can be used:


The result of this call will be a boolean true or false representing the subscription status of the visitor.

Determining if a Visitor is Eligible to Prompt

If you need to determine if the visitor meets all requirements to be prompted for push permission run the following JavaScript:

await PushlySDK.context.user.isEligibleToPrompt({
websitePushId: PushlySDK.context.domain.apnsConfiguration?.push_package?.website_push_id

The result of this call will be a boolean true or false representing if the visitor is eligible to be shown a permission dialog.

Requiring Visitor Consent

For site visitors subject to GDPR we recommend disclosing and receiving consent from these visitors when they initially visit your site. For these visitors, the SDK should be initialized with the consentRequired boolean flag set to true:

<script src="" async></script>
var PushlySDK = window.PushlySDK || [];
function pushly() { PushlySDK.push(arguments) }
pushly('load', {
domainKey: 'DOMAIN_KEY',
consentRequired: true

This initialization parameter can also be used to specify that a visitor has opted out of data collection.

When this flag is provided, the SDK will be initialized but will not perform any actions until the confirm_consent method is called. This method should be called immediately after the visitor has accepted your consent notice.


Soft Unsubscribe

If you need to perform a soft unsubscribe on the subscriber run the following JavaScript:


This method works only as a soft unsubscribe. If the subscriber clears their cookies they may get re-opted into notifications.

Soft Re-Subscribe

If a visitor has soft unsubscribed they can be re-subscribed by running the following JavaScript: