Product Requirements |
Privy's audience targeting rules are a collection of conditions that allow you to target individuals with specific displays so that you can display the right message, to the right person, at the right time. This guide reviews how to leverage some custom JavaScript to show a display to individuals who are or are not logged in during their visit.
Note: The steps outlined below are provided based on the assumption that you've already created a Convert display that includes an onsite display (e.g., Popup).
Target logged-in visitors
To add a targeting condition that will only show the display to visitors who are logged into their Shopify account for your store:
- Navigate to the Convert > All Displays via the main navigation.
- Select or create a display and navigate to the Target step in the display builder.
- Select the Who To Show It To section and then the Add targeting condition button.
- Select the Custom JavaScript option from the Property dropdown menu.
- Paste the code listed below into the Value field.
if (window.__st) { return (__st.cid != null);
} return false;
- Click the Save button to lock in your new targeting conditions.
That's it! Your display will now only include visitors who are logged into their store accounts.
Target logged-out visitors
To add a targeting condition that will only show the display to visitors who are logged out of their Shopify account for your store:
- Navigate to the Convert > All Displays via the main navigation.
- Select or create a display and navigate to the Target step in the display builder.
- Select the Who To Show It To section and then the Add targeting condition button.
- Select the Custom JavaScript option from the Property dropdown menu.
- Paste the code listed below into the Value field.
if (window.__st) {
return (__st.cid == null);
}
return true;
- Click the Save button to lock in your new targeting conditions.
That's it! Your display will now only include visitors who are logged out of their store accounts.