SDK API Reference
The API Reference for our JavaScript SDK
window.postscript
When the SDK is installed properly, you should be able to reference it using window.postscript
.
window.postscript.identify
Identifies a subscriber on your site.
Usage:
window.postscript.identify({
phone: "555-555-5555"
});
Payload | Description |
---|---|
{ "phone": "555-555-5555" } | A JSON payload object to use to identify the subscriber. It must have a phone field to look the subscriber up by. |
Returns result indicating whether or not a subscriber was found and if so, that they were cookied.
window.postscript.event
Fires an event for a subscriber.
Usage:
window.postscript.event('event_name', payload);
Supported Events
Event Name | Payload | Description |
---|---|---|
page_view | { "shop_id": "123456", "url": "https://example.myshopify.com/products/antique-drawers", "search_params": { "variant": "123456789" } "page_type": "product", "referrer": "https://example.myshopify.com/collections/all", "resource": { "category": "Indoor", "name": "Antique Drawers", "price_in_cents": 25000, "resource_id": 123456789, "resource_type": "product", "sku": null, "variant_id": 123456789, "vendor": "Company 123" } } | Fires an event for Subscriber Viewed Product. For use in "Subscriber Viewed Product" automations (i.e. Browse Abandonment). |
add_to_cart | { "shop_id": "123456", "url": "https://example.myshopify.com/products/antique-drawers", "search_params": { "variant": "123456789" } "page_type": "product", "referrer": "https://example.myshopify.com/collections/all", "resource": { "category": "Indoor", "name": "Antique Drawers", "price_in_cents": 25000, "resource_id": 123456789, "resource_type": "product", "sku": null, "variant_id": 123456789, "vendor": "Company 123" } } | Fires an event for Product Added to Cart. For use in "Product Added to Cart" automations (i.e. Browse Abandonment). |
window.postscript.getSubscriberId
Returns a Postscript Subscriber ID if found.
Usage:
window.postscript.getSubscriberId();
Updated about 1 year ago