> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wegive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Tag Manager

> Set up GTM triggers, data-layer variables, custom listeners, and supported Google identity mapping.

Connect your Google Tag Manager container to WeGive, then configure triggers and variables to send checkout events to your reporting destinations.

## Connect and configure

1. Create or select a web GTM container. For Google Analytics reporting, create/select your GA4 property and configure its Google tag in GTM.
2. In WeGive's Integrations area, open **Google Tag Manager Setup**, enter **Google Tag Manager Container ID** (for example `GTM-ABC1234`), and save.
3. In GTM, create a **Custom Event** trigger for the exact WeGive event you need, then Data Layer Variables for its fields. Connect those variables to your destination tag and publish through your organization's normal GTM process.

`givingDetails` reports advancement from the Giving step, and `donationConfirmed` reports donation-completion continuations. `value.frequency` describes gift frequency; `value.coverFees` indicates fee coverage. Consult the [shared catalog](/external/onboarding/tracking/standard-events) for portal/layout availability and exact units: `donationConfirmed.value.amount` is cents, while `value.amount_dollars` and ecommerce `value` are major currency units. Do not assume a funnel event's `value.amount` has the same units as a conversion.

| Use | Trigger / variable |
| - | - |
| Donation completion | `donationConfirmed` |
| Confirmed successful payment | `donationSuccess` |
| New recurring plan | `recurringPlanCreated` |
| Conversion amount in major units | `value.amount_dollars` on the three events above |
| Conversion currency | `value.currency_code` |
| Ecommerce revenue | `purchase` → `ecommerce.value`, `ecommerce.currency` |
| Session join | `wegive.checkout_session_uuid` |
| Checkout / campaign | `wegive.checkout_id`, `wegive.campaign_id` |
| Current gift frequency | `wegive.frequency` |

Use an exact Custom Event trigger rather than a broad substring match when similar names could collide. Choose one signal per intended conversion. Counting both `purchase` and `donationSuccess` as independent successful gifts duplicates revenue. A recurring-plan creation is not necessarily an immediate payment. The data layer also receives context updates without an `event` key; a push count or array position is not a checkout milestone.

## Native data layer and custom interactions

In GTM's **Variables** area, create a **Data Layer Variable** (Version 2) for each field your tags use, such as `wegive.checkout_session_uuid` and `wegive.frequency`. Give each variable a descriptive name, then select it in your destination tag's field mapping. `window.dataLayer` is a message array; `window.dataLayer.wegive` is not the current context. See [Google's data-layer documentation](https://developers.google.com/tag-platform/tag-manager/datalayer).

Use a Custom HTML tag that runs inside the checkout window to install the following listener. When pasting into a Custom HTML tag, wrap the JavaScript in script tags. Configure it to install once; its guard also prevents duplicate installation. Delegation observes fields mounted after the tag runs.

```javascript theme={null}
if (!window.myOrganizationGtmAddressListener) {
  window.myOrganizationGtmAddressListener = true;
  document.addEventListener('blur', function (event) {
    if (!event.isTrusted) return;
    var control = event.target.closest && event.target.closest('[data-checkout-control="address-street"]');
    if (!control || control.getAttribute('data-checkout-context') !== 'mailing') return;
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({ event: 'custom_mailing_address_edit' });
  }, true);
}
```

Create a Custom Event trigger for `custom_mailing_address_edit`. In the tag triggered by that event, map your Data Layer Variables for session UUID and frequency to the destination's fields. The example pushes just an event; GTM reads the current context already published by WeGive. It does not require another WeGive accessor or a search through old data-layer entries. Expanded sharing makes donor variables available separately, but this example sends no contact values itself.

Your event name, rules, and mappings belong to you. Observe native blur in document capture to read current donor values; custom selectors and hosted fields use the paths in the [hook reference](/external/onboarding/tracking/checkout-hooks).

## Optional Google identity

In WeGive select **Donor sharing → Expanded donor details**, then click **Save** at the bottom of the integration settings form. In GTM create a Version 2 Data Layer Variable named **DLV - WeGive Google identity**, with Data Layer Variable Name `wegive_user_data`. Create a Custom JavaScript variable returning that value:

```javascript theme={null}
function () {
  return {{DLV - WeGive Google identity}} || undefined;
}
```

The double braces are GTM variable references, not browser JavaScript to paste into the console. Select this Custom JavaScript variable as the **Code** data source of a **User-Provided Data** variable. For GA4, enable the required property feature and connect that variable through the supported `user_data` parameter following [Google's setup instructions](https://support.google.com/analytics/answer/14179230?hl=en). Google Ads has its own enhanced-conversions configuration. Publishing the WeGive object alone does not enable either destination.

Use that supported identity route rather than mapping raw contact fields into ordinary Analytics parameters. Off and Existing fields only do not populate `wegive_user_data`. Review the [sharing contract](/external/onboarding/tracking/donor-sharing) for sharing settings, defaults, partial values, and mixed integrations.

## Preview and diagnose

Open GTM Preview against the checkout's actual URL. Inspect the data-layer event and current variables, trigger match, tag execution, and destination receipt separately. Inspect the checkout frame for embedded flows. Verify UUID availability, sharing settings, pending payments, and deferred recurring plans. A GTM event does not prove destination delivery.

See [Setup requirements](/external/onboarding/tracking/setup-requirements) for the validation checklist.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.