Skip to main content

Campaign Testing in Production

When deploying campaigns it is often a good idea to do a final check before campaigns are opened to site users. Best practice would be to build and test templates and campaigns in a non-production environment, but even in this situation a final check in production is a good idea. There may be small environmental differences, or an error in the copy / recreation of a non-prod to prod item may introduce unexpected issues.


The general process is:

  • Create a isTestUser user attribute
  • Create a segment for test users
  • Code the sitemap to set attribute to true based on query string
  • Set campaign inclusion rule for test user attribute only


Create the attribute:
Under settings > attributes, create an attribute with the name isTestUser and a type of Boolean.

Code the sitemap:
In your sitemap, add code the global config to watch for a specific query parameter to be passed. Suggest using the following:

global: {
    onActionEvent: (actionEvent) => {
        if ('isTestUser') > -1) {
            actionEvent.user = actionEvent.user || {};
            actionEvent.user.attributes = actionEvent.user.attributes || {};
            actionEvent.user.attributes.isTestUser = true;
        return actionEvent;

Set campaign inclusion rule:
Build your campaign and set a Campaign Targeting rule to limit viewing where the attribute isTestuser = true. Publish your campaign.

Access the site as a test user:

Navigate to the page that contains the test campaign and append to the URL ?isTestUser=true, as long as there is no existing query string. So the url becomes If the URL already contains a query string, append with an &. So becomes This will trigger the sitemap code to set your user attribute to be flagged as a test user.

You are now a flagged as a test user and can fully test the experience in a live environment without risk of exposing to additional users.

Do not forget to remove the Campaign Targeting rule once you are ready to launch the campaign for users. For ongoing testing the attribute and sitemap changes can remain in the platform.

Alternate Option - No Sitemap Change:
If you would prefer not to set the global action in your sitemap, instead of indicating you are a test user through the query string you can send an event in through your browser's console. Just run: Evergage.sendEvent({action: 'testUser', user: { attributes: {isTestUser: true}}});. This will set the attribute on your user without a sitemap change or URL tweak. I prefer the former approach because it's easy for non-technical users to use if you have a number of individuals that should be testing campaigns before public launch.