Skip to main content

How to Show a Poper Popup After a JavaScript Event

The After a JavaScript Event trigger lets you show a popup only after a specific JavaScript event happens on your website.

Written by Karan Bhakuni

Use this trigger when you want the popup to appear after actions like:

  • user login

  • add to cart

  • checkout started

  • quiz completed

  • form submitted

  • custom button click

  • any custom tracking event

This trigger is useful when normal triggers like page load, scroll, click, or exit intent are not enough.


What is a JavaScript Event?

A JavaScript event is a signal sent by your website when something happens.

For example, your website can fire an event like:

window.dispatchEvent(new CustomEvent("user_login"));

If Poper is listening for user_login, the popup will open when that event is fired.


How to Set It Up

1) Open Display Conditions

Open your popup in the Poper editor and go to:

Display Conditions > Trigger

2) Select “After JavaScript Event”

Inside the Trigger section, choose:

After JavaScript Event

3) Enter the Event Name

Enter the exact event name you want Poper to listen for.

Example:

user_login

You can also use names like:

add_to_cart checkout_started quiz_completed

Important: The event name must match exactly.
For example, user_login and User_Login are different.

4) Save the Popup

Save your popup and make sure it is published or active on your website.

5) Fire the Event From Your Website

Your website or developer needs to dispatch the same event name.

Example:

window.dispatchEvent(new CustomEvent("user_login"));

When this code runs, Poper detects the event and shows the popup.


Full Example

If you set this event name in Poper:

add_to_cart

Your website should fire:

window.dispatchEvent(new CustomEvent("add_to_cart"));

When the visitor adds a product to cart, the popup will open.


Example With Extra Data

You can also send additional data with the event:

window.dispatchEvent(   new CustomEvent("checkout_started", {     detail: {       cartValue: 120,       currency: "USD"     }   }) );

Poper only needs the event name to open the popup. The extra detail data is optional.


Testing the Feature

You can test this from your browser console.

Open your website and run:

window.dispatchEvent(new CustomEvent("user_login"));

If your popup is configured with user_login, it should appear.


Device Targeting

You do not need to set desktop or mobile inside this trigger.

Use Poper’s Device display condition separately to control whether the popup shows on desktop, mobile, or both.

  • Device condition = desktop / mobile targeting

  • After JavaScript Event = which event opens the popup


Important Notes

  • The event must fire after the Poper script has loaded.

  • If the event fires before Poper is ready, Poper will not detect it.

  • The event name must match exactly.

  • Make sure the popup is active or published.

  • Check your Device and Frequency conditions if the popup does not appear.

  • The event must fire on the same page where Poper is installed.


Common Event Name Examples

You can use any event name you want. Examples:

user_login add_to_cart checkout_started purchase_completed quiz_completed form_submitted video_watched plan_selected

Use simple lowercase names with underscores for clarity.


Summary

The After a JavaScript Event trigger gives you more control over when your popup appears.

Instead of showing the popup immediately, on scroll, or on exit intent, you can show it after a custom action happens on your website.

Example:

window.dispatchEvent(new CustomEvent("user_login"));

Poper listens for that event and opens the popup when it happens.

Did this answer your question?