# Google Tag

Read or switch on a Google Ads account's Google tag, manage its website conversion actions and auto-tagging, check conversion counts, and install it on Shopify or WordPress.

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

Every Google Ads account has exactly one Google tag (`AW-<id>`). Its website conversion actions are the events a site fires through it.

## Read the tag

Zernio exposes that tag under the platform-neutral [tracking tags API](/guides/pixels) on your `googleads` connection. You can:

- read its code and conversion labels
- switch conversion tracking on
- set auto-tagging
- create and edit its website conversion actions
- see conversion counts
- install it on a connected [Shopify](/platforms/shopify/tracking-pixels) store or [WordPress](/platforms/wordpress/tracking-pixels) site

This is the site tag. The campaign's click-URL tracking template is a different thing, on [URL tracking tags](/platforms/google-ads/url-tracking).

`GET /v1/accounts/{accountId}/tracking-tags` lists one tag per customer on the connection. It does not call Google, so it costs no quota.

`GET .../tracking-tags/{tagId}` reads the tag's settings and conversion actions, and adds the gtag.js base `code`. `tagId` is the customer id (see [Ids](#ids)).

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data } = await zernio.trackingtags.getTrackingTag({
  path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d', tagId: '1234567890' }
});
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

data = client.tracking_tags.get_tracking_tag(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    tag_id="1234567890",
)
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tracking-tags/1234567890" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "platform": "googleads",
  "tag": {
    "id": "1234567890",
    "name": "Google tag (Acme Store)",
    "platform": "googleads",
    "kind": "tag",
    "status": "active",
    "ownerAdAccountId": "1234567890",
    "siteTagId": "AW-16799533812",
    "code": "<!-- Google tag (gtag.js) -->\n<script async src=\"https://www.googletagmanager.com/gtag/js?id=AW-16799533812\"></script>...",
    "events": [
      {
        "id": "7012345678",
        "name": "Purchase",
        "type": "PURCHASE",
        "status": "ENABLED",
        "siteEventId": "AbC-D_efG123hIjK",
        "siteEvent": "purchase"
      }
    ]
  }
}
```

`status` is `inactive` while the account does not track conversions.

Reads go through Zernio's Google read cache, so repeated reads do not call Google each time.

## Ids

| Field | Value |
|-------|-------|
| `accountId` | The `googleads` connection |
| `tagId` | The customer id, 10 digits (`123-456-7890` and `1234567890` both work). The tag is per customer, so the tag id is the customer id. |
| `siteTagId` | `AW-<conversion tracking id>`: what gtag.js loads. Under cross-account conversion tracking it is the manager account's id. |
| `events[].id` | The conversion action id |
| `events[].siteEventId` | The conversion label from the action's event snippet (`send_to: 'AW-.../<label>'`) |

`events` holds the account's `WEBPAGE` conversion actions. GA4-imported and upload actions are not fired from a page.

On `GET .../tracking-tags/{tagId}` only enabled ones appear. The `/events` list also returns removed (archived) ones.

`siteEvent` is set when the action's category maps to a storefront event:

| Category | `siteEvent` |
|---|---|
| `PAGE_VIEW` | `page_view` |
| `ADD_TO_CART` | `add_to_cart` |
| `BEGIN_CHECKOUT` | `initiate_checkout` |
| `PURCHASE` | `purchase` |

## Conversion counts

`GET .../tracking-tags/{tagId}/stats` returns one row per conversion action with `conversionActionId`, `conversionActionName`, `category`, `allConversions` and `allConversionsValue`.

The window defaults to the last 30 days. `startTime` and `endTime` (Unix seconds) are applied as whole days in the account's time zone, so an edge can shift by a day.

`aggregation` is Meta only and answers `400` here.

## Switch the tag on and set auto-tagging

`POST /v1/accounts/{accountId}/tracking-tags` with `adAccountId` (the customer id) and `name` is idempotent on Google.

An account that already tracks conversions gets its existing tag back, and nothing is created.

Otherwise Zernio creates a `WEBPAGE` conversion action named `name` (category `DEFAULT`) and returns the tag. That action is what turns Google's conversion tracking on.

`PATCH .../tracking-tags/{tagId}` takes `autoTagging` (`true` or `false`), for gclid auto-tagging. It is the only tag-level setting the Google Ads API lets Zernio write. Every other tag field answers `400`.

## Conversion events

The tag's events are its `WEBPAGE` conversion actions, managed on `/tracking-tags/{tagId}/events`:

| Field | Meaning |
|-------|---------|
| `name` | Unique per customer, so a replayed create fails with a duplicate-name error instead of making a second action |
| `type` or `siteEvent` | A `ConversionActionCategory` (`PURCHASE`, `ADD_TO_CART`, `BEGIN_CHECKOUT`, `PAGE_VIEW`, `SIGNUP`, `DEFAULT`, ...), or `page_view`, `add_to_cart`, `initiate_checkout`, `purchase` (the other site events have no Google category and answer `400`) |
| `defaultValue`, `currency`, `alwaysUseDefaultValue` | The action's value settings |
| `clickWindowDays`, `viewWindowDays` | Lookback windows, 1 to 90 and 1 to 30 days |
| `primary` | Primary for goal (counts toward bidding) or secondary |
| `countingType` | `one` (one per click) or `every` (every conversion) |
| `enabled` | `false` removes the action; `true` restores a removed one |

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: created } = await zernio.trackingtags.createTrackingTagEvent({
  path: { accountId: '66b2e19d8c3f5a7e9d0b1c2d', tagId: '1234567890' },
  body: { name: 'Add to cart', siteEvent: 'add_to_cart', countingType: 'every', primary: false }
});
```
</Tab>
<Tab value="Python">
```python
created = client.tracking_tags.create_tracking_tag_event(
    account_id="66b2e19d8c3f5a7e9d0b1c2d",
    tag_id="1234567890",
    name="Add to cart",
    site_event="add_to_cart",
    counting_type="every",
    primary=False,
)
```
</Tab>
<Tab value="curl">
```bash
curl -X POST "https://zernio.com/api/v1/accounts/66b2e19d8c3f5a7e9d0b1c2d/tracking-tags/1234567890/events" \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Add to cart", "siteEvent": "add_to_cart", "countingType": "every", "primary": false }'
```
</Tab>
</Tabs>

Response (`201`), with the conversion label read back from Google:

```json
{
  "platform": "googleads",
  "event": {
    "id": "7012345699",
    "name": "Add to cart",
    "type": "ADD_TO_CART",
    "status": "ENABLED",
    "siteEvent": "add_to_cart",
    "siteEventId": "XyZ-1a_bC2dEfGh3",
    "primary": false,
    "countingType": "every",
    "clickWindowDays": 30,
    "viewWindowDays": 1
  }
}
```

`DELETE .../events/{eventId}` removes the action, which on Google is an archive (`state: "archived"`). Google keeps it as `REMOVED` with its history, and `PATCH` with `enabled: true` restores it.

An action is always created enabled.

The same actions are also reachable as [website tag actions](/platforms/google-ads/conversions#website-tag-actions).

## What the API cannot do

| Operation | Answer | Evidence |
|-----------|--------|----------|
| Share the tag | `501` | Cross-account conversion tracking (`google_ads_conversion_customer`) answers `403 SERVICE_ACCESS_DENIED` to every write from Zernio's developer token, because Google allowlists it; set it up from the manager account in the Google Ads UI. |
| Diagnostics | `501` | `ConversionAction` (API v25) has no tag status or last-fired field, and there is no test-event service. Use the stats or Google Tag Assistant. |
| Change the tag id or enhanced conversions for leads | Not offered | Both are output-only in the Google Ads API (the tag id is `conversion_tracking_id`). Every other `conversion_tracking_setting` write besides `autoTagging` answers `SERVICE_ACCESS_DENIED`. |
| Disable an event without removing it | Not offered | Google answers `400 BLOCKED_VALUE` to `HIDDEN` on `WEBPAGE` actions, so `enabled: false` removes (archives). |
| Delete the tag | Not offered | The tag is the customer's own `AW-` id, part of the account. |

## Install on a store

`POST .../tracking-tags/{tagId}/install` with a `storeAccountId` installs the tag. What it fires depends on the conversion actions:

- **Shopify**: Google counts only events that have their own conversion action.
  - The store sends a conversion only for `page_view`, `add_to_cart`, `initiate_checkout` and `purchase`.
  - It sends one only when the account has an enabled `WEBPAGE` action of the matching category with a label. The primary-for-goal action wins, then the lowest id.
  - Product views, searches and payment info are never sent. Google has no category for search or payment info, and pointing product views at the page-view action would count every product page twice.
  - A tag with no mapped action installs but sends nothing. See [the event mapping](/platforms/shopify/tracking-pixels#event-mapping).
- **WordPress**: the gtag.js base code (its `config` call is the page view) plus the `PAGE_VIEW` conversion snippet when the account has one. The official fallback is Google's **Site Kit by Google** plugin.

Install calls read the tag first. Re-install after you add or relabel conversion actions, because the store keeps the labels it was installed with.

## If it fails

| Error | Cause | Fix |
|---|---|---|
| `400` on `PATCH .../tracking-tags/{tagId}` | The body sets a tag field other than `autoTagging`, the only one Google lets Zernio write | Send `autoTagging` alone |
| `400` on an event's `siteEvent` | The site event has no Google category | Use `page_view`, `add_to_cart`, `initiate_checkout` or `purchase`, or a `type` |
| Duplicate-name error on an event create | Event names are unique per customer, so a replayed create fails | Read the `/events` list before creating again |
| `400` on `aggregation` for stats | `aggregation` is Meta only | Leave it out |
| `501` on share or diagnostics | Google does not offer them to Zernio's developer token | See [What the API cannot do](#what-the-api-cannot-do) |

## Related

- [Pixels and tracking tags](/guides/pixels): the cross-platform model and capability matrix.
- [Conversions](/platforms/google-ads/conversions): server-side uploads and conversion goals.
- [URL tracking tags](/platforms/google-ads/url-tracking): the campaign's tracking template and final URL suffix.
- [Get tracking tag](/tracking-tags/get-tracking-tag) and [Install on a store](/tracking-tags/install-tracking-tag-on-store): every field.