How to test Amped popups against other types of popups using Google Tag Manager

Steps for setting up GTM to test Amped vs other popups at the same time

1. Sign in to your Google Tag Manager account and navigate to the container where you want to add the tag.

2. In Google Tag Manager, create a new tag and give it a name (e.g. "Popup Type Set Tag for Experiment").

3. In the tag configuration, select "Custom HTML" as the tag type.

4. In the HTML field, add the following code:


<script type="text/javascript">
// Check if the "popup_type" cookie is set
if (!document.cookie.match(/popup_type=[^;]+/)) {
    // If the cookie is not set, generate a 50% chance of setting it to "Amped" or "Other"
    var popupType = Math.random() < 0.5 ? "Amped" : "Other";
    // Set the cookie at the domain level
    document.cookie = "popup_type=" + popupType + ";domain=yoursite.com;path=/";
    // Trigger a Google Analytics event
    if (typeof gtag === "function") {
        // If the website uses Google Analytics 4, use this method to trigger the event
        gtag("event", popupType, {
            event_category: "Popup Type Set",
        });
    } else if (typeof ga === "function") {
        // If the website uses the older version of Google Analytics, use this method to trigger the event
        ga("send", "event", "Popup Type Set", popupType);
    }
}
<script>

5. Be sure to replace "yoursite.com" in the code with your website's domain name. This allows the cookie to live at the domain level and work across subdomains.

6. In the trigger configuration, select the "All Pages" trigger that will fire this tag.

7. Save the tag and publish your changes in Google Tag Manager.

8. Then set your Campaigns in Amped and your other popups to only show if the cookie of popup_type matches the respective platform