ShopMessage's Growth Plugins allow merchants to prompt site visitors to subscribe in Messenger at the right time. However, you may want more granular control. You can use the following functions.

SDK Setup

You must first ensure that you have added the ShopMessage setup script to your site. For Shopify users, this is done automatically through the Shopify app. For all other merchants, you can find the script in your ShopMessage Dashboard under Settings.

This will ensure that you have the _shopmsg  object created.

Show an Overlay Growth Plugin

You can use the "overlay.render"  function and pass in the Growth Plugin's widget id to manually show overlay plugins like Modals, Flyouts, and Page Takeovers.
Example:

_shopmsg("overlay.render", 26600);

The following caveats apply:

  1. This only works with overlays (i.e. not with individual checkboxes, send-to-messenger buttons)
  2. this does not work with minimized state, it just goes straight to the open/initial state
  3. it overrides any display rules (behaviors) the merchant has defined
  4. it will render even if the visitor is logged out of Facebook

Get Facebook Login Status

Use this function to determine if the customer is logged in to Facebook in the browser session.

_shopmsg('facebook.loginStatus', function(isLoggedIn) {
  console.log('visitor is logged in to facebook');
});

Note: If the visitor is not logged into facebook, then your function will never be invoked.

Get Visitor Optin Status

This function tells you whether the user is already opted in to Messenger in their browser session.

_shopmsg('visitor.optinStatus', function(isOptedIn) {
  console.log(`visitor is opted in? ${isOptedIn}`);
});

Listen for JavaScript Events

You have the ability to trigger various user events based on users' on-site activity. You can also listen for when these events are fired.

_shopmsg('addEventListener', 'NameOfEvent', function(data) {
 // the contents of 'data' depends on what the event is
 console.log(data);
});

To see what kinds of events are fired, you can use the ShopMessage Integration Helper Chrome Extension

Did this answer your question?