> For the complete documentation index, see [llms.txt](https://docs.anedot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md).

# Tracking Codes for Action Pages

Add Google Analytics 4, Google Tag Manager, Meta Pixel, X Pixel, and X Event ID to Donation Pages, Event Pages, and Lead Pages, and reuse them with presets.

**Tracking codes** connect your Action Pages to Google Analytics 4 (GA4), Google Tag Manager (GTM), the Meta (Facebook) Pixel, and the X (Twitter) Pixel, so you can measure visits, donations, and signups. You add them in the Page Builder under **Setup > Settings > Tracking codes**. This article covers adding tracking codes, Settings presets, each tracking tool, embedded pages, UTM parameters, when tracking fires, and testing your setup.

## Before You Begin

* To add or change tracking codes and Settings presets, you need **Action Pages: Edit permissions**. Without them, the Page Builder shows a View-only access notice and you can't save. See [Permission Sets](https://docs.anedot.com/settings/access/permission-sets.md).
* Donation Pages, Event Pages, and Lead Pages all use the same **Setup > Settings > Tracking codes** section.
* Tracking codes are set on each page or on the Settings preset the page uses. There's no account-wide tracking codes screen.
* Tracking doesn't run in the Page Builder preview. Test on your live page.

## Supported Tracking Codes

| Tool               | Field in Tracking Codes                                                 | What It Sends                                                                                               |
| ------------------ | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Google Analytics 4 | **Google Analytics** and **Send e-commerce events to Google Analytics** | Page views, donation and lead events, and e-commerce `purchase` events                                      |
| Google Tag Manager | **Google Tag Manager**                                                  | Loads your container and pushes donation and lead events to the data layer                                  |
| Meta Pixel         | **Facebook Pixel**                                                      | PageView, Purchase, and Lead events                                                                         |
| X (Twitter) Pixel  | **X Pixel**, **X Event ID**                                             | Page views, plus a conversion after a successful gift, ticket purchase, or sign-up when both fields are set |

* The fields accept IDs only. You can't paste a pixel script into a page.
* There's no built-in field for other tools, such as TikTok, LinkedIn, or Google Ads. Add those tags through your own GTM container. See [Add Other Tags Through GTM](https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md#add-other-tags-through-gtm).

## Add Tracking Codes to an Action Page

To add tracking codes:

1. Go to **Action Pages > Action Pages** and open your page in the Page Builder.
2. In the left menu, under **Setup**, select **Settings**.
3. In the **Tracking codes** section, enter the IDs you use.
4. Click **Save**.

Your changes go live when you save. There's no separate publish step, but the live page can take about a minute to show the update.

### Tracking Code Fields

* **Google Analytics:** Your GA4 Measurement ID, which starts with G- (for example, G-XXXXXXXXXX). Up to 16 characters.
* **Send e-commerce events to Google Analytics:** Sends a GA4 `purchase` event for each donation on Donation Pages and Event Pages.
* **Google Tag Manager:** Your GTM Container ID, which starts with GTM- (for example, GTM-XXXXXXXX). Up to 12 characters.
* **Google origin allowlist:** Fill this in only when the page is embedded on your website. See [Embedded Pages](https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md#embedded-pages).
* **Facebook Pixel:** Your Meta Pixel ID. Up to 17 characters.
* **X Pixel:** Your X Pixel ID.
* **X Event ID:** The event ID from your X Ads conversion event, in the form tw-xxxxx-xxxxx. This field sits directly under **X Pixel**. You need both fields for Anedot to report conversions to X.

{% hint style="warning" %}
Anedot doesn't check the format of most of these IDs. A mistyped ID saves without an error but doesn't track, so copy each ID exactly. Google Tag Manager and X Pixel IDs that contain anything other than letters, numbers, underscores, or hyphens are ignored. **X Event ID** is the exception: it must be blank or match the tw-xxxxx-xxxxx form, or the page won't save and you'll see "X event id is invalid".
{% endhint %}

## Use Settings Presets

A **Settings preset** saves your tracking codes so you can reuse them across pages. Every account starts with a preset named **Default**, and new pages use it. You manage presets in the **Settings preset** section of **Setup > Settings**.

* **Select a preset:** Applies that preset to the page. Applying a preset replaces the tracking codes on the page.
* **Save:** Saves your tracking code changes to this page only. The preset and other pages that use it don't change.
* **Update Preset:** Saves your tracking code changes to the preset itself, which updates every page that uses it. Before you confirm, the dialog shows how many pages use the preset.
* **Save as Preset:** Saves the page's current settings as a new named preset. Save the page to attach it to the new preset.
* **Apply to pages…:** Opens **Update Pages to Preset**, where you choose the pages that should use the preset.

For more on presets, see [Presets in the Page Builder](https://docs.anedot.com/action-pages/page-builder/presets-in-the-page-builder.md).

### Change Tracking Codes on Every Page That Uses a Preset

To update a preset:

1. Go to **Action Pages > Action Pages** and open any page that uses the preset.
2. In the left menu, under **Setup**, select **Settings**.
3. In the **Tracking codes** section, update the IDs.
4. Click **Update Preset**.
5. Review the number of pages that use the preset, then confirm.

The message "Updated "\[preset name]"." appears, and every page that uses the preset loads the new tracking codes.

{% hint style="info" %}
A page that was edited and saved on its own keeps its own copy of the tracking codes and doesn't pick up later preset updates. To bring it back to the preset, use **Apply to pages…**.
{% endhint %}

### Apply A Preset to Several Pages

To apply a preset:

1. Open a page that uses the preset, and go to **Setup > Settings**.
2. In the **Settings preset** section, click **Apply to pages…**.
3. In **Update Pages to Preset**, select the pages, or select **All Pages**.
4. Click **Apply**.

The message "Applied "\[preset name]" to \[number] action pages." appears, and the selected pages use the preset's tracking codes.

## Google Analytics 4 (GA4)

Send GA4 data one way only. Use either the built-in **Google Analytics** field or your own GTM container, not both.

* **Built-in field (recommended for most accounts):** Enter your Measurement ID in **Google Analytics** and check **Send e-commerce events to Google Analytics**. Anedot sends page views and `purchase` events for you.
* **Your GTM container:** Leave **Google Analytics** empty and leave the e-commerce box unchecked. Build your GA4 tags in GTM on Anedot's data layer event. See [Send GA4 Purchases From GTM](https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md#send-ga4-purchases-from-gtm).

{% hint style="warning" %}
If you add the same GA4 Measurement ID in the **Google Analytics** field and in your GTM container, page views and purchases can be counted twice.
{% endhint %}

### Set Up GA4

To set up GA4 with the built-in field:

1. In Google Analytics, go to **Admin > Data streams**, select your web stream, and copy the **Measurement ID**.
2. In the Page Builder, go to **Setup > Settings** and paste the whole ID, including G-, in **Google Analytics**.
3. Check **Send e-commerce events to Google Analytics**.
4. Click **Save**. If your pages use more than one Settings preset, repeat these steps for each preset.
5. In Google Analytics, go to **Admin > Events** and make sure `purchase` is marked as a key event.

Use the Measurement ID from a web stream. Don't use a Property ID, a GT- tag ID, a UA- ID, or a GTM- ID in this field.

### What Anedot Sends to GA4

| Event                   | When It Fires                                                                                                  | Details                                                                                                      |
| ----------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `page_view`             | The page loads                                                                                                 | Standard GA4 page data                                                                                       |
| `purchase`              | A donation succeeds on a Donation Page or Event Page, and **Send e-commerce events to Google Analytics** is on | `transaction_id`, `value`, `currency` (USD), `affiliation` (page name), and one item (one-time or recurring) |
| "\[Page name] donation" | A donation succeeds on a Donation Page or Event Page                                                           | A custom event with the donation value                                                                       |
| "\[Page name] lead"     | A Lead Page signup succeeds                                                                                    | A custom event with no value                                                                                 |

* All values are in U.S. dollars.
* GA4 data is sent from the donor's browser only. Anedot doesn't send GA4 data from its servers.
* To tell your pages apart in GA4 reports, use the page path or the `affiliation` (page name) on each purchase.

{% hint style="info" %}
Use `purchase` as your GA4 key event. The "\[Page name] donation" event names contain spaces, so they don't work well as key events.
{% endhint %}

## GA4 Cross-Domain Tracking

Cross-domain tracking keeps a donor's GA4 session together when they move from your main website to your Action Page, so donations are credited to the campaign that brought the donor in.

{% hint style="info" %}
These steps are our recommended setup:

1. Use the same GA4 Measurement ID on your main website and in every Settings preset your Action Pages use.
2. Check **Send e-commerce events to Google Analytics**, then click **Save**.
3. Add GA4 one way only, either in the Google Analytics field or in GTM.
4. If your Action Pages use a different root domain or secure.anedot.com, go to **Admin > Data streams** in Google Analytics, select your web stream, and select **Configure tag settings > Configure your domains**. Add your main domain, your custom domain, and anedot.com. Pages on a subdomain of your website, such as give.example.org, don't need this step.
5. In **Configure tag settings**, click **Show all**, then select **List unwanted referrals**. Add your own domains, anedot.com, paypal.com, and opennode.com.
6. In your web stream's **Enhanced measurement** settings, open **Page views**, show the advanced settings, and turn off **Page changes based on browser history events**.
7. Mark `purchase` as a key event.
   {% endhint %}

## Google Tag Manager (GTM)

GTM lets you add your own marketing and analytics tags, such as Google Ads conversion tags, to your Action Pages.

To add GTM:

1. In Google Tag Manager, copy your **Container ID** (for example, GTM-XXXXXXXX).
2. In the Page Builder, go to **Setup > Settings** and paste the ID in **Google Tag Manager**.
3. Click **Save**.

Use one container per page. To use the same container on many pages, add it to a Settings preset. See [Use Settings Presets](https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md#use-settings-presets).

### What Anedot Sends to the Data Layer

When a donation or signup succeeds, Anedot pushes one event to the data layer:

| Event                                    | Page Types                     |
| ---------------------------------------- | ------------------------------ |
| `google_analytics_ecommerce_transaction` | Donation Pages and Event Pages |
| `generate_lead`                          | Lead Pages                     |

Anedot pushes this event for every successful donation or signup, whether or not **Send e-commerce events to Google Analytics** is on. Each push includes these fields:

* **transactionId:** The submission ID.
* **transactionTotal:** The donation total in U.S. dollars (donations only).
* **predictedLtv:** An estimated lifetime value in cents, based on the recurring frequency (donations only).
* **gift\_type:** One-time or recurring.
* **fName**, **lName**, **city**, **state**, **postalCode**, and **country:** The donor's name and location.

The data layer doesn't include email, phone, or UTM fields. To use UTM values in GTM, use GTM's built-in Page URL or Query variables.

### Fire A Tag on a Donation or Signup

The receipt opens on the same page without a full page reload, so page view, DOM Ready, and "/receipt" page path triggers don't fire when a donation succeeds. Use a Custom Event trigger on Anedot's data layer event instead.

#### Step 1: Create the Trigger

To create the trigger:

1. In GTM, go to **Triggers** and click **New**.
2. Choose **Custom Event** as the trigger type.
3. For **Event name**, enter `google_analytics_ecommerce_transaction`. For Lead Pages, enter `generate_lead`.
4. Name the trigger and click **Save**.

#### Step 2: Create the Variables

To create a variable for the donation amount:

1. Go to **Variables** and click **New**.
2. Choose **Data Layer Variable**.
3. For **Data Layer Variable Name**, enter `transactionTotal`.
4. Name the variable and click **Save**.

Repeat these steps with `transactionId` if your tag needs an order or transaction ID.

#### Step 3: Create Your Tag

To create your tag:

1. Go to **Tags** and click **New**, then choose your tag type, such as **Google Ads Conversion Tracking**.
2. Enter the tag's details. For a conversion value, select your `transactionTotal` variable.
3. Under **Triggering**, select the Custom Event trigger from Step 1.
4. Click **Save**, then submit and publish your container.

### Send GA4 Purchases From GTM

If you send GA4 data through GTM instead of the built-in field, your own GTM tags must send the `purchase` event.

To send purchases from GTM:

1. Create a GA4 event tag with the event name `purchase`.
2. Set `transaction_id` to your `transactionId` variable, `value` to your `transactionTotal` variable, and `currency` to USD.
3. Under **Triggering**, select the `google_analytics_ecommerce_transaction` Custom Event trigger.
4. Click **Save**, then submit and publish your container.

Leave the **Google Analytics** field empty on your Action Pages so purchases aren't counted twice.

### Add Other Tags Through GTM

To add a tool without a built-in field, such as TikTok or LinkedIn, add that tool's tag to your GTM container and fire it on the Custom Event trigger from [Fire a Tag on a Donation or Signup](https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md#fire-a-tag-on-a-donation-or-signup).

Use `transactionTotal` for the donation value.

{% hint style="warning" %}
Load your Meta Pixel one way only, either in the **Facebook Pixel** field or in your GTM container. Loading it both ways counts events twice.
{% endhint %}

### GTM Restrictions on Action Pages

Anedot blocks GTM's **DOM Element** and **JavaScript Variable** variable types on Action Pages. Use Data Layer Variables for donation details. If a tag needs one of the blocked variable types, contact our Support team about removing the restriction for your account.

## Meta (Facebook) Pixel

The **Meta Pixel** tracks visits, donations, and signups in the donor's browser.

To add the Meta Pixel:

1. Copy your Meta Pixel ID from your Meta account.
2. In the Page Builder, go to **Setup > Settings** and paste the ID in **Facebook Pixel**.
3. Click **Save**.

### Meta Events

| Event    | When It Fires                                                                        | Details                                                                                                                                                                            |
| -------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PageView | The page loads                                                                       | None                                                                                                                                                                               |
| Purchase | A donation succeeds on a Donation Page or Event Page, after the payment is confirmed | Value in U.S. dollars, currency (USD), one-time or recurring, predicted lifetime value, and the donor's email, name, city, state, ZIP code, and country, sent only as hashed codes |
| Lead     | A Lead Page signup succeeds                                                          | Hashed email                                                                                                                                                                       |

PageView and Purchase are separate events, so a page view and a donation from the same donor aren't double counted.

{% hint style="info" %}
Hashed means each detail is scrambled into a code before it's sent. Meta can match it to a Meta account but never sees the actual details.
{% endhint %}

## X (Twitter) Pixel

The **X Pixel** and **X Event ID** fields connect your Action Page to X Ads, so X can count page views and conversions from your page.

To set up X tracking:

1. Copy your X Pixel ID and the event ID from your X Ads conversion event.
2. In the Page Builder, go to **Setup > Settings**.
3. In the **Tracking codes** section, enter the pixel ID in **X Pixel** and the event ID in **X Event ID**. The event ID looks like tw-xxxxx-xxxxx, with letters and digits in each part.
4. Click **Save**.

Your changes go live when you save.

### What X Receives

* **Page views:** Recorded whenever **X Pixel** is set, even if **X Event ID** is blank.
* **Conversions:** Reported from the donor's browser after a successful gift, ticket purchase, or sign-up, when both **X Pixel** and **X Event ID** are set. The conversion includes the amount in U.S. dollars (USD).
* **Lead Pages:** Report a conversion with an amount of 0.
* **Failed or declined submissions:** Send nothing to X.

{% hint style="warning" %}
You need both fields for conversions. An **X Event ID** without an **X Pixel** sends nothing, and an **X Pixel** without an **X Event ID** records page views only.
{% endhint %}

{% hint style="info" %}
When **Hide client-side Facebook pixel** is turned on, X tracking doesn't run, for either page views or conversions. Meta Pixel events don't run either.
{% endhint %}

The Page Builder preview never sends tracking, including X conversions. To test, submit a gift or sign-up on your live page.

**X Event ID** is part of your page's Settings, like **X Pixel** and the other tracking codes. Pages that share a Settings preset also share the same **X Pixel** and **X Event ID**.

## Embedded Pages

**Google origin allowlist:** Only fill this in if your page is embedded on your own site and you want donation events sent to that site. Enter full addresses like `https://www.example.org`, separated by commas. If you also use Google Tag Manager on this page, contact Support first.

* Leave **Google origin allowlist** empty on pages that aren't embedded.
* For more accurate tracking, link to your Action Page instead of embedding it.

## UTM Parameters

**UTM parameters** are tags you add to the end of an Action Page link to show where your traffic comes from. GA4 reads them from the page URL, and Anedot keeps them on the URL without adding or removing any, so you don't need to set anything up in Anedot.

Add UTM parameters whenever you share an Action Page link, such as in ads, emails, text messages, social posts, partner links, or QR codes. For example:

`https://secure.anedot.com/account-url-slug/page-slug?utm_source=facebook&utm_medium=paid&utm_campaign=year_end_appeal`

| Parameter     | Description                                   |
| ------------- | --------------------------------------------- |
| utm\_source   | Traffic source (for example, facebook)        |
| utm\_medium   | Channel (for example, email, social, or cpc)  |
| utm\_campaign | Campaign name (for example, fall\_fundraiser) |
| utm\_content  | Ad or test variant (for example, button\_a)   |
| utm\_term     | Search term for paid keyword campaigns        |

UTM data appears in GA4 Acquisition reports as source, medium, and campaign. For other parameters Action Pages support, see [URL Parameters](https://docs.anedot.com/action-pages/advanced-features/url-parameter.md).

## When Tracking Fires

* **Page load:** Each tracking code loads and records a page view.
* **Successful donation or signup:** Donation and signup events fire in the donor's browser after the payment is confirmed. Declined or failed payments don't send these events.
* **Receipt:** The receipt opens on the same page without a full page reload. Opening a receipt link directly doesn't send tracking events.
* **Callback URL:** If your page uses a **Callback URL**, Anedot sends the tracking events before it redirects the donor.
* **Event Pages:** Ticket purchases are tracked as donations, and ticket prices are included in the total.
* **Lead Pages:** Send lead events (`generate_lead` in GTM and Lead in Meta) with no value, even when the page collects money.
* **Recurring gifts:** Tracking codes run in your donor's browser, so they record a recurring gift once: when the donor signs up and makes the first payment. That event includes the first payment's amount and marks the gift as recurring. Later scheduled payments happen automatically without the donor on your page, so they don't send events to Meta, Google Analytics, Google Tag Manager, or X.
* **Future pledges:** Tracked at signup, with today's charge as the value.
* **Post-conversion upgrades:** Each accepted upgrade sends its own purchase event with its own transaction ID.
* **Not tracked:** Bitcoin checkouts that redirect away from the page, and gifts entered in **Finance > Terminal**.
* **Amount, currency, and ID:** Amounts are in U.S. dollars, the currency is always USD, and the transaction ID is the submission ID. If one checkout creates more than one submission, the IDs are joined with commas.

{% hint style="info" %}
When a donor opens your page from a social media app, such as Facebook or Instagram, they may be asked to open it in their phone's browser before they pay. Analytics tools may then count them as a new visitor.
{% endhint %}

## Test Your Setup

To test your tracking codes:

1. Open your live Action Page, not the Page Builder preview, in a private browser window with ad blockers turned off.
2. Open your testing tools, such as Google Tag Assistant or GA4 DebugView, GTM Preview, and the Meta Pixel Helper browser extension.
3. Confirm that a page view appears in each tool.
4. Make a small real donation, or submit a Lead Page signup.
5. Confirm that the donation or lead events appear in each tool.

{% hint style="warning" %}
Voiding or refunding a test donation doesn't remove events that were already sent to Google, Meta, or X.
{% endhint %}

## Related Articles

* [Page Settings: SEO, Sharing, and Tracking](https://docs.anedot.com/action-pages/page-builder/page-settings-seo-sharing-and-tracking.md)
* [Presets in the Page Builder](https://docs.anedot.com/action-pages/page-builder/presets-in-the-page-builder.md)
* [Page Builder Overview](https://docs.anedot.com/action-pages/page-builder.md)
* [Custom Domain & Email Branding](https://docs.anedot.com/settings/configuration/custom-domain-and-email-branding.md)
* [URL Parameters](https://docs.anedot.com/action-pages/advanced-features/url-parameter.md)
* [Permission Sets](https://docs.anedot.com/settings/access/permission-sets.md)
* [Advanced Features](https://docs.anedot.com/action-pages/advanced-features.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.anedot.com/action-pages/advanced-features/tracking-codes-for-action-pages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
