[GA4] Set custom campaign data

You can set custom campaign data in Google Analytics 4. Campaign data values can be set via parameters in gtag.js and via Google Tag Manager.

Note that if you have auto-tagging enabled, gtag.js cannot be used to override gclid information.

Set campaign values in gtag.js

To set campaign values globally, use gtag('set', ...) and add fields prefixed with campaign_:

gtag('set', {
    'campaign_id': 'google_1234',
    'campaign_name': 'Summer_fun',
    'campaign_source': 'google',
    'campaign_medium': 'cpc',
    'campaign_term': 'summer+travel',
    'campaign_content': 'logolink',
});

You can add campaign values in gtag.js for a specific Google Analytics ID with gtag('config' ...):

gtag('config', 'G-12345', {
    'campaign_id': 'google_1234',
    'campaign_name': 'Summer_fun',
    'campaign_source': 'google',
    'campaign_medium': 'cpc',
    'campaign_term': 'summer+travel',
    'campaign_content': 'logolink',
});

For a list of all supported campaign fields, refer to the developer documentation.

Set campaign values in Tag Manager

To set campaign values in Google Tag Manager, use Fields to Set.

  1. In Google Tag Manager, open the relevant workspace.
  2. Click Tags and then click the name of the Google Analytics 4 Configuration tag you want to work with.
  3. Click Tag Configuration > Fields to Set.
  4. Click the Add Row button for each field you want to add. Consider the table below for example values:
    Field Name Example value
    campaign_id google_1234
    campaign_name Summer_fun
    campaign_source facebook
    campaign_medium cpc
    campaign_term summer+travel
    campaign_content logolink
  5. Click Save to save your tag configuration.
  6. Submit your changes and publish the container.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu