Trigger Campaigns By Button Click


If you're wanting to trigger a popup campaign on a button click from your site you can accomplish this exact use case by setting up an anchor link on the button on your site  (ex: <a href=“#open_signup"></a>)


Prepare the Anchor Link on Your Site

Add an anchor link to your website. Example: <a href="#show_signup"></a>. This link will serve as the conditions for your campaign to show.

Set Up the Campaign in Amped

Visitor Segment: Select 'All Visitors' as you want this to show anytime the link is clicked (you could use others but Amped will consider all the targeting rules vs “All Visitors” is more wide open)

Trigger Configuration: Use “Time on page of 0 seconds”

Page Targeting: Choose “Currently Viewing a page URL” that contains "#show_signup" or whatever you set in your anchor link.

Frequency Setting: Set this to 'Once per page view' to activate the campaign each time the link is clicked.

Safe Display Setting: Choose 'Autonomous' under 'Safe Display' so that the campaign shows regardless of if the visitor has seen other Amped campaigns recently.

Add Code for #Hashtag Removal

You will want to make sure the X's on all steps, as well as the last step CTA to return to site all include a piece of custom code to remove the hashtag from the url so that your campaign doesn't continually fire.

1.) Navigate to the X's/last step CTA > Button Actions > Add Action

2.) Select "Custom Code"

3.) Rename to "Remove #" and paste script into body, then save! 

Here is the script to use in your campaign

// Remove the Hash fragment from the URL
function removeHashFragment() {
  if (window.location.hash) {
    // Remove any hash fragment while keeping the pathname and search parameters
    history.replaceState(null, null, window.location.pathname + window.location.search);
  }
}

// Call the function to remove the hash fragment if present
removeHashFragment();



resolve(); // resolve(); tells your ad to continue. Othwerwise the ad will load indefinitely, break, and it will timeout.

Copy this process on each X (on all steps) as well as the last step CTA to ensure whenever the campaign is closed, the hashtag is removed.

Publish the Campaign

Reminder you will need to publish your campaign for this to work! Once it's live, you will be able to open the campaign on the button click from your site!