Use this guide if your site loads Google Analytics 4 through Google Tag Manager (GTM). Once you've set it up, you can see your OptiMonk campaigns' performance in GA4.

OptiMonk sends one event, optimonk_campaign_event, for campaign impressions, signups, "no thanks" clicks and closes. Your visitors' cookie consent applies.

1. Turn on event reporting for your domain

Nothing is sent until you turn this on.

  1. In OptiMonk, go to Settings → Domains.

  2. Open the row of your domain.

  3. Turn on Analytics event reporting.

This switch applies to every campaign on the domain. You can check its state on any campaign's Integrations tab, on the Google Analytics card.

If Google Analytics runs directly on your site, without Tag Manager, you're done. If you use Tag Manager, continue with step 2.

  1. In the same domain row, click Download container. The OM_GA4.json file downloads. The button only appears while Analytics event reporting is on.

  2. Open Google Tag Manager, go to Admin, then Import Container.

    Untitled

  3. Select OM_GA4.json, choose your workspace, and select Merge so your existing tags are kept.

    Untitled

  4. The import adds these items to your workspace:

    • Tags: GA4 - OptiMonk and GA4 - OM Multi-campaign A/B test

    • Triggers: OptiMonk campaign event and OptiMonk multi-campaign A/B test event

    • Variables: OM - campaign name, OM - campaign id, OM - variant name, OM - action, OM - experience name, OM - group name and OM - ab test name

    Untitled

  5. Open both tags and replace the placeholder measurement ID (G-1234) with your own GA4 measurement ID.

    Untitled

  6. Save, then Submit and publish your changes in Tag Manager.

To find your measurement ID, go to Admin → Data Streams in GA4 and click the data stream that receives your site's traffic.

Untitled

Untitled

3. Or set up Tag Manager manually

Skip this step if you imported the container.

  1. Create four Data Layer Variables (version 2):

    Variable nameData Layer Variable Name
    OM - campaign namecampaign_name
    OM - campaign idcampaign_id
    OM - variant namevariant_name
    OM - actionaction
  2. Create a Custom Event trigger with the event name optimonk_campaign_event.

    Untitled

  3. Click New Tag and choose Google Analytics: GA4 Event as the tag type.

    Untitled

    Untitled

  4. Enter your GA4 measurement ID, and set the event name to optimonk_campaign_event.

    Untitled

    Untitled

  5. Add these event parameters:

    Parameter nameValue
    om_campaign_name{{OM - campaign name}}
    om_campaign_action{{OM - action}}
    om_campaign_id{{OM - campaign id}}
    om_campaign_variant_name{{OM - variant name}}

    Untitled

  6. Set the trigger from step 2 as the firing trigger, then save the tag.

    Untitled

  7. Submit your changes in Tag Manager.

    Untitled

The event at a glance

Each optimonk_campaign_event in GA4 carries these parameters:

ParameterDescription
om_campaign_nameThe campaign's name
om_campaign_idThe campaign's ID
om_campaign_variant_nameThe variant (A/B test) name
om_campaign_actionWhat the visitor did: impression, conversion, closex or rejected

Action values: impression (the campaign was shown), conversion (the campaign was filled out), closex (the visitor clicked the closing X) and rejected (the visitor clicked a "no thanks" link).

4. Set up custom definitions in Google Analytics 4

  1. Open Google Analytics 4, go to Admin, then Custom definitions.

    Untitled

  2. Create these four custom definitions:

    • OptiMonk Campaign Name (om_campaign_name)

    • OptiMonk Campaign Action (om_campaign_action)

    • OptiMonk Campaign ID (om_campaign_id)

    • OptiMonk Campaign Variant Name (om_campaign_variant_name)

    Untitled

❗ After this, wait up to 24 hours before you continue. GA4 needs this time to recognise the events, because most GA4 settings are not real-time.

5. Set up audiences

Create two audiences based on the event:

  • OptiMonk Shown: users who have seen any OptiMonk campaign (at least 1 impression).

  • OptiMonk Filled: users who have filled out any OptiMonk campaign (at least 1 conversion).

You can also create audiences for closex (users who clicked the closing X) and rejected (users who clicked a "no thanks" link).

  1. In Google Analytics 4, go to Admin and click New audience.

    Untitled

  2. In the Include Users dropdown, find optimonk_campaign_event.

    Untitled

  3. Choose OptiMonk Campaign Action as the parameter, choose the contains match type, and set it to impression.

    Untitled

  4. Repeat this for the conversion audience: OptiMonk Campaign Action contains conversion.

    Untitled

After 24 hours, you can use these audiences.

6. Use the audiences in reports

  1. Open a report and click Add comparison.

    Untitled

  2. In Build comparison, choose Audience name as the dimension.

    Untitled

  3. Pick OptiMonk Shown or OptiMonk Filled.

    Untitled

    Untitled