Opt-in Tools - External Triggers
Table of Contents
Using External Triggers with Recart Popups
External triggers allow you to control when your Recart popups appear using your own custom code or third-party applications. Instead of relying on Recart's standard display rules, you can programmatically trigger popups based on your specific business logic.
What Are External Triggers?
External triggers give you programmatic control over popup display timing through JavaScript. This is useful when you want to integrate popup displays with other actions on your site, such as:
- Showing a popup after a specific user action
- Triggering popups based on custom conditions you've defined
- Integrating popup displays with third-party tools
- Creating complex display logic beyond standard trigger options
How External Triggers Work
When you use an external trigger, Recart still applies your popup's device, geo-targeting, and URL targeting settings. However, the timing of when the popup appears is controlled entirely by your code.
External triggers will:
- Respect device filtering (mobile/desktop)
- Apply geo-targeting rules from your popup Settings
- Apply URL targeting from your popup Settings
- Follow configuration rules for SMS popups
External triggers will not:
- Ignore successful subscription (the popup will display even if a visitor has previously closed it)
Finding Your Code Snippet
When you select "External Trigger" as your trigger type in the popup editor, Recart automatically displays the code snippet you need. This snippet includes your specific popup ID.
Basic implementation:
window._recart.showOptinTool("YOUR_POPUP_ID")
Simply copy this code and implement it wherever you want the popup to trigger on your site.
Force Display Option
For advanced use cases where you need a popup to display even when another popup is already active (open or minimized), you can add a force parameter:
window._recart.showOptinTool("YOUR_POPUP_ID", { force: true })
This is primarily useful when displaying a secondary popup after a visitor interacts with your first popup.
Note: Use the force option carefully, as showing popups too aggressively may negatively impact customer experience.
A/B Testing with External Triggers
If you're running A/B tests with externally triggered popups, Recart provides a method to retrieve which popup variant should be displayed:
const activePopupId = window._recart.getActiveOptinToolInExperiment(EXPERIMENT_ID)
window._recart.showOptinTool(activePopupId)
This code snippet is also shown in the popup editor when you add A/B testing to an externally triggered popup.
Troubleshooting
If your external trigger isn't working as expected, check the following:
- Popup ID: Ensure the popup ID in your code matches your actual popup ID
- Popup Status: Verify your popup is published and active
- Targeting Settings: Confirm your device, geo, and URL targeting settings allow the popup to display in your test scenario
- Script Loading: Make sure your trigger code runs after the Recart script has loaded
- Console Errors: Check your browser's developer console for JavaScript errors
Need Help?
External triggers offer powerful customization options. If you have questions about implementing external triggers or need assistance with your specific use case, please contact our support team through the chat widget or by emailing support@recart.com.