Skip to content

Trigger Engage Messages on Button or Link Click

Trigger an Icegram Engage popup or message when a visitor clicks a button, menu item, or text link using shortcodes or click classes.

Icegram Engage allows you to launch campaigns (such as popups, action bars, or messengers) when a visitor clicks on a button, link, or image. There are two ways to achieve this depending on your plan:

  1. Method 1: Shortcode Wrapper (Free & Pro plans)
  2. Method 2: JavaScript Trigger (Pro plan)

Method 1: Using the Shortcode Wrapper

You can wrap any HTML link or button inside an Icegram campaign shortcode. When clicked, the campaign opens automatically.

  1. Configure your campaign and message in Icegram Engage.

  2. In the campaign settings, copy the campaign shortcode. It looks like: [icegram campaigns="CAMPAIGN_ID"]

    Copy campaign shortcode from Icegram Engage

  3. On the post or page where you want the link or button, wrap your element in the shortcode:

    For a text link:

    [icegram campaigns="1234"]<a href="#">Click here for the offer!</a>[/icegram]

    Shortcode wrapping a link

    For a button:

    [icegram campaigns="1234"]<button type="button">Claim Discount</button>[/icegram]

    Shortcode wrapping a button


Method 2: Using the JavaScript Trigger Pro

In Icegram Engage Pro, you can trigger any specific message directly using a JavaScript snippet on any button, navigation menu item, or element with an onclick attribute.

  1. In your campaign editor, navigate to the message you want to display.

  2. Under the Show Trigger dropdown, select Using JavaScript.

  3. Icegram Engage will display the custom JavaScript code snippet. It looks like:

    window.icegram.get_message_by_id(1234).show();

    Show Trigger set to Using JavaScript in Icegram Engage

  4. Configure any other campaign display rules and save your campaign.

  5. Add the JavaScript snippet to the onclick handler of your button or link:

    Button example:

    <button onclick="window.icegram.get_message_by_id(1234).show(); return false;">
      Open Special Offer
    </button>

    Button with JavaScript onclick trigger

    Link example:

    <a href="#" onclick="window.icegram.get_message_by_id(1234).show(); return false;">
      Open Special Offer
    </a>

    Link with JavaScript onclick trigger