# Wascer DB

> Wascer DB stores data on your sGTM server as JSON documents by key. Learn how to turn it on, use the GTM templates and read and write through the Database API.

**Wascer DB** is a NoSQL database built into Wascer's Server-Side Google Tag Manager (sGTM). It stores data on the server as key-value pairs, without relying on third-party cookies or external services such as Firestore or Supabase.

With browsers blocking more and more cookies and laws such as LGPD and GDPR adding restrictions, keeping data in the browser has become increasingly fragile. Wascer DB moves that storage to the server: your data is not affected by cookie blocking, browser extensions or cache clearing.

In practice, you store JSON documents identified by a unique key and organized into collections. Each document holds up to 500 KB of data and is kept for 90 days after it is created. In sGTM, the **Wascer Store Writer** and **Wascer Store Read** templates write to and read from the database. Outside sGTM, any system can use the Database API, with no extra infrastructure.

![Database section of the container, with the Active status and the default collection](https://blog.wascer.com/api/media/file/image-109.webp?v=1793990084201)

*Wascer Dashboard: Database section with Active status, collections and container metrics*

## Benefits

- **Server-side persistence:** data stays on the server, unaffected by cookie blocking, ITP, ETP and ad blockers.
- **Cross-session identification:** recognizes users across sessions without relying on the browser, for attribution windows of up to 90 days.
- **LGPD and GDPR:** to fulfill a deletion request (Art. 18 LGPD, Art. 17 GDPR), delete the document through the Database API. Documents also expire on their own after 90 days.
- **No external services:** Wascer DB runs on the same infrastructure as your container. Reads and writes do not go through third-party services.
- **No infrastructure to set up:** no database to provision, no OAuth credentials to configure and no connections to manage. Turning it on takes one click.
- **Ready-made sGTM templates:** Wascer Store Writer (tag) writes and Wascer Store Read (variable) reads, with no code.
- **Full HTTP API:** list, create, read, replace, update, delete and search documents from any backend, CRM or data pipeline.
- **Security:** data stays on the server and is never sent to the user's browser. Outside GTM, access requires a Database API key.
- **Included in your plan:** Wascer DB comes with paid plans, from Starter up, with no per-operation charge.

## How it works

### Key-value architecture in sGTM

Wascer DB stores JSON documents, each with a **unique key** (document key), grouped into **collections**:

- **Collections:** group documents by topic, such as `user_profiles`, `attribution` or `capping`.
- **Documents:** JSON objects identified by a unique key within the collection. The document data (`data`) can take up to 500 KB.
- **Fields:** live inside `data`. A field nested in another one is written with a dot, such as `consent.analytics`.

**Data model**

```json
{
  "document_key": "user_abc123",
  "collection": "user_profiles",
  "data": {
    "email_hash": "a1b2c3d4e5f6",
    "first_seen": "2026-01-15T10:30:00Z",
    "total_sessions": 14,
    "ltv": 2450.00,
    "consent": { "analytics": true, "marketing": false }
  },
  "created_at": "2026-01-15T10:30:00.000Z",
  "updated_at": "2026-02-02T18:04:11.000Z"
}
```

### Data flow

1. The **user's browser** sends a request (page view, event) to your sGTM address on Wascer.
2. The **sGTM container** processes the event and, through a tag or variable, reads from or writes to Wascer DB.
3. Wascer DB **writes or returns** the document for the given key, such as the User ID or Client ID.
4. The data read is **added to the event** before the destination tags fire, such as Google Analytics 4, Meta Conversions API and TikTok Events API.

## How to turn it on and set it up

### Turn on Wascer DB

1. Sign in to the Wascer dashboard at [app.wascer.com](https://app.wascer.com).
2. In **Containers**, open the container where you want to use Wascer DB.
3. Click the **Database** tab.
4. If the tab shows **Activate the database**, click **Activate database**. A confirmation message appears (in Portuguese, **Banco de dados ativado com sucesso!**).
5. Done: Wascer DB can now be used by the templates and the Database API. Once it is on, it cannot be turned off from the dashboard.

![Active Database section, with the totals and the list of collections](https://blog.wascer.com/api/media/file/image-105.webp?v=1793990083126)

*Wascer Dashboard: active Database section*

### Create collections

After turning it on, create collections to organize your documents. The **default** collection already exists.

1. In the **Database** tab, click **+ New**, next to **Collections**.
2. In the **New collection** dialog, type the name. Use only letters, numbers, hyphens and underscores.
3. Click **Create**.

![New collection window with the name field empty](https://blog.wascer.com/api/media/file/image-6-1400x708.webp?v=1793990118898)

*New collection creation modal: input field with placeholder ‘e.g.: users’*

![New collection window with the name Wascer filled in](https://blog.wascer.com/api/media/file/image-110.webp?v=1793990082293)

*Modal filled with the name ‘Wascer’ ready for creation*

### Manage it from the dashboard

In the **Database** tab you can browse the documents in each collection, search by key, inspect the content, edit or delete fields and move documents to another collection. See the step by step in [Container database](https://wascer.com/be-fr/helpdesk/containers-no-painel/banco-de-dados-do-container).

### Official templates

The **Download templates** button, in the **Database** tab, opens the Wascer Store, where you find the official templates. They are also on GitHub:

| Template | Type | What it does |
| --- | --- | --- |
| Wascer Store Writer | Tag | Writes data to the database using a document key. [GitHub](https://github.com/sourei-tech/wascer-store-writer) |
| Wascer Store Read | Variable | Reads a field value by document key (Document ID), field name (Field Name) and collection (Collection). [GitHub](https://github.com/soureiBR/wascer-store-read) |

## Step by step: import and set up the templates in sGTM

This section shows how to import the Wascer Store Writer (tag) and Wascer Store Read (variable) templates into Server-Side Google Tag Manager, with screenshots of each step.

### Step 1: download the templates from the Wascer dashboard

**1. Sign in to the Wascer dashboard** and open the container. Check that it is **Running** and that the database is on, in the **Database** tab.

![Wascer dashboard menu with the Wascer Store option highlighted](https://blog.wascer.com/api/media/file/Captura-de-tela-2026-05-19-091135-1400x686.webp?v=1793990116774)

*Wascer Dashboard: sGTM container with Running status, configured domains and Smart Cache active*

**2. Open the Wascer Store** from the sidebar. It shows the templates for Server-Side GTM: Wascer Store Writer (tag), Wascer Store Read (variable), Data Client Wascer, Firestore Writer, Google Sheets and Google Offline.

**3. Click Download .zip** on the templates you want to import. For Wascer DB, download **Wascer Store Writer** and **Wascer Store Read**.

![Wascer Store page with the available templates and the Download .zip buttons](https://blog.wascer.com/api/media/file/Captura-de-tela-2026-05-19-091045-1400x693.webp?v=1793990081768)

*Wascer Store page: all available templates with “Baixar .zip” (Download) button*

**Template repositories on GitHub:**

- **Wascer Store Writer** (tag): [github.com/sourei-tech/wascer-store-writer](https://github.com/sourei-tech/wascer-store-writer)
- **Wascer Store Read** (variable): [github.com/soureiBR/wascer-store-read](https://github.com/soureiBR/wascer-store-read)
- **Data Client Wascer** (client): [github.com/soureiBR/Data-Client-Wascer](https://github.com/soureiBR/Data-Client-Wascer)
- **Firestore Writer Wascer** (tag): [github.com/soureiBR/Firestore-Writer-Wascer](https://github.com/soureiBR/Firestore-Writer-Wascer)
- **Google Sheets** (tag): [github.com/soureiBR/google-sheets-template](https://github.com/soureiBR/google-sheets-template)
- **Google Offline** (tag): [github.com/soureiBR/google-data-manager-template](https://github.com/soureiBR/google-data-manager-template)

### Step 2: import the tag template (Wascer Store Writer)

**4. Open GTM** with the **Open GTM** button at the top of the container in the Wascer dashboard. In the workspace sidebar, click **Templates** (Modelos, if your GTM is in Portuguese).

![Server-side GTM workspace, with Templates highlighted in the menu](https://blog.wascer.com/api/media/file/image-119.webp?v=1793990079498)

*sGTM Workspace: arrow pointing to “Modelos” (Templates) in the left sidebar*

**5. On the Templates page**, you see three sections: Client templates, Tag templates and Variable templates. Click **New** in **Tag templates**.

![GTM Templates page with Wascer Store Read under Variable templates](https://blog.wascer.com/api/media/file/image-115.webp?v=1793990078703)

*Templates page: “Novo” (New) button highlighted in the “Tag templates” section*

**6. In the Template Editor**, click the three-dot menu in the top right corner and choose **Import**.

![GTM template editor, with the Import option highlighted in the menu](https://blog.wascer.com/api/media/file/image-108.webp?v=1793990077878)

*Template Editor: dropdown menu with “Importar” (Import) option highlighted*

**7. Select the Wascer Store Writer .tpl file** that came inside the .zip. The template loads with its name, description and icon.

![Wascer Store Writer template imported in GTM, with the Save button highlighted](https://blog.wascer.com/api/media/file/image-107.webp?v=1793990077189)

*Wascer Store Writer template imported: name, description and icon loaded automatically*

**8. Check the box** "I agree to the Community Template Gallery Terms of Service" and click **Save**. The template is also on the [Wascer Store Writer GitHub](https://github.com/sourei-tech/wascer-store-writer).

![Wascer Store Writer template imported in GTM, with the terms checked and the Save button highlighted](https://blog.wascer.com/api/media/file/image-118.webp?v=1793990076483)

*Terms of Service checkbox checked and “Salvar” (Save) button highlighted*

### Step 3: import the variable template (Wascer Store Read)

**1. Go back to the Templates page** and click **New** in **Variable templates**.

![GTM Templates page, with the New button under Variable templates highlighted](https://blog.wascer.com/api/media/file/image-114.webp?v=1793990075749)

*Templates page: “Novo” (New) button highlighted in the “Variable templates” section*

**2. In the Variable Template Editor**, click the three-dot menu and choose **Import**.

![GTM variable template editor, with the Import option highlighted in the menu](https://blog.wascer.com/api/media/file/image-116.webp?v=1793990075054)

*Variable Template Editor: dropdown menu with “Importar” (Import) option*

**3. Select the Wascer Store Read .tpl file.** The template loads with the name Wascer Store Read and the description "The value is set to the value from a key in a Wascer Store document". The template is also on the [Wascer Store Read GitHub](https://github.com/soureiBR/wascer-store-read).

**4. Check the Terms of Service box** and click **Save**.

![Wascer Store Read template imported in GTM, with the terms checked](https://blog.wascer.com/api/media/file/image-101-1400x686.webp?v=1793990098739)

*Wascer Store Read imported: name, description and Terms checkbox checked*

**5. Check the import:** the Wascer Store Read template appears in the Variable templates list.

![GTM Templates page with Wascer Store Read under Variable templates](https://blog.wascer.com/api/media/file/image-115.webp?v=1793990078703)

*Templates page: “Wascer Store Read” listed in Variable templates*

### Step 4: create a tag with Wascer Store Writer

1. In the sidebar, click **Tags** and then **New**.
2. In **Tag type**, choose **Wascer Store Writer**, the template you imported.
3. In **Triggering**, choose when the tag fires, for example **All Pages** for every page.
4. Name the tag, such as `Wascer_Store_Writer_Tag`, and click **Save**.

![Wascer_Store_Writer_Tag with the Wascer Store Writer template and the All Pages trigger](https://blog.wascer.com/api/media/file/image-117.webp?v=1793990074252)

*Wascer Store Writer tag configuration with “All Pages” trigger*

![GTM tag list with Wascer_Store_Writer_Tag and the All Pages trigger](https://blog.wascer.com/api/media/file/image-113.webp?v=1793990073450)

*Tags list: “Wascer_Store_Writer_Tag” created with All Pages trigger*

### Step 5: create the Wascer Store Read variable

1. In the sidebar, click **Variables** and then **New**, in the User-Defined Variables section.
2. In **Variable type**, choose **Wascer Store Read**, the template you imported.
3. Fill in the fields:

- **Document ID:** the document key. It accepts variables, such as `{{Document_ID}}`.
- **Field Name:** the name of the field you want to read, such as `page_view`.
- **Collection (optional):** the document's collection, such as `Wascer`.

![Wascer Store Read variable with Document ID, Field Name and Collection filled in and the Save button highlighted](https://blog.wascer.com/api/media/file/image-111.webp?v=1793990072794)

*Wascer Store Read variable filled: Document ID {{Document_ID}}, Field Name “page_view”, Collection “Wascer”*

**4. Name the variable**, such as `Wascer_Store_Read`, and click **Save**.

Done: the templates are set up in sGTM. The Wascer Store Writer tag writes to the database every time it fires, and the Wascer Store Read variable can be used in any tag or trigger to read what was written.

## Read and write through the Database API

Outside GTM, for example in a backend, a CRM, a spreadsheet or an AI agent, use the container's Database API. The full reference, with every field and response, is in the [Database API documentation](https://wascer.com/docs).

### Before you start

1. Create a Database API key with the `database:access` scope. It starts with `pk_` and begins working within 2 minutes. See [Database API keys](https://wascer.com/be-fr/helpdesk/conta-equipe-e-seguranca/chaves-da-database-api).
2. Note the container domain: the same one as your server-side GTM, which can be the container's Wascer address or your custom domain.

### Base URL

```plaintext
https://<container domain>/wascer-api/<pk_ key>/v1/store
```

The key goes in the URL path, with no authentication header. So treat the whole URL as a password.

### Endpoints

| Method | Path, after the base URL | What it does |
| --- | --- | --- |
| GET | `/collections` | Lists the collections. |
| POST | `/collections` | Creates a collection, with the body `{"name": "purchases"}`. |
| GET | `/collections/{collection}/documents` | Lists documents by creation date, up to 500 per page. |
| POST | `/collections/{collection}/documents` | Creates a document. Returns 409 if the key already exists. |
| GET | `/collections/{collection}/documents/{key}` | Reads a document. |
| PUT | `/collections/{collection}/documents/{key}` | Creates or replaces a document. |
| PATCH | `/collections/{collection}/documents/{key}` | Updates the fields you send, at the first level of `data`. |
| DELETE | `/collections/{collection}/documents/{key}` | Deletes a document. Returns 204. |
| POST | `/collections/{collection}/documents/query` | Searches documents by a field in `data`. |

Lists and searches return `next_cursor`. For the next page, repeat the call with that cursor (`cursor=` in the list address, `"cursor"` in the search body) until it comes back as `null`.

### Examples

```plaintext
BASE="https://<container domain>/wascer-api/$WASCER_API_KEY/v1/store"

# List the collections
curl -s "$BASE/collections"

# Create a document
curl -s -X POST "$BASE/collections/user_profiles/documents" \
  -H 'Content-Type: application/json' \
  -d '{"document_key":"uid_7f3a9c2e","data":{"segment":"new_customer","consent_analytics":true}}'

# Read the document
curl -s "$BASE/collections/user_profiles/documents/uid_7f3a9c2e"

# Update a field
curl -s -X PATCH "$BASE/collections/user_profiles/documents/uid_7f3a9c2e" \
  -H 'Content-Type: application/json' \
  -d '{"data":{"segment":"returning_customer"}}'

# Find the documents that have a gclid
curl -s -X POST "$BASE/collections/attribution/documents/query" \
  -H 'Content-Type: application/json' \
  -d '{"filter":{"conditions":[{"field":"gclid","operator":"exists"}]}}'

# Delete the document
curl -s -X DELETE "$BASE/collections/user_profiles/documents/uid_7f3a9c2e"
```

Response when reading a document:

```json
{
  "document_key": "uid_7f3a9c2e",
  "collection": "user_profiles",
  "data": {
    "segment": "returning_customer",
    "consent_analytics": true
  },
  "created_at": "2026-05-15T10:30:00.000Z",
  "updated_at": "2026-05-20T08:12:45.000Z"
}
```

In searches, the operators are `equal`, `not-equal`, `exists`, `not-exists`, `contains`, `not-contains`, `gt`, `gte`, `lt` and `lte`, with up to 10 conditions combined with `and` or `or`. A nested field is written with a dot, such as `user_data.email`. Each call reads at most 1,000 documents: while `next_cursor` is not `null`, there may still be results, even if the page comes back empty.

### Limits

| Item | Limit |
| --- | --- |
| Document data (`data`) | Up to 500 KB. |
| Document key | Up to 2,054 characters, unique in the collection. |
| Collection name | Letters, numbers, hyphens and underscores, up to 64 characters. |
| Document lifetime | 90 days after creation. With `ttl` (in seconds) at creation, it can be shorter. Updating does not extend it. |
| Listing | Up to 500 documents per page. |
| Field search | Up to 1,000 documents read per call and up to 10 conditions. |

Integers above 2^53, such as very long order IDs, are returned as strings.

### Errors

Error responses include `code` and `message`.

| HTTP | What it means |
| --- | --- |
| 400 | Invalid body, filter, cursor or name. |
| 403 | Wrong or revoked key, or a key without the `database:access` scope. |
| 404 | The document does not exist. |
| 409 | The document key already exists (on creation). |
| 413 | The data is larger than 500 KB. |
| 503 | The API is not active on the container yet: create the key and wait 2 minutes. |

### Inside sGTM

To read and write inside sGTM, use the **Wascer Store Writer** and **Wascer Store Read** templates, as in the step by step above. They need no code.

## Use cases

### Cross-session attribution with gclid and fbclid

A user reaches your store for the first time through a Google Ads campaign. sGTM writes the **gclid** to Wascer DB, linked to the user's identifier. Days later, the same user comes back directly and buys. sGTM reads the stored gclid and attributes the conversion to the original campaign, even if the browser cookies were cleared. The document is kept for up to 90 days.

**Stored document:**

```json
{
  "document_key": "uid_7f3a9c2e",
  "collection": "attribution",
  "data": {
    "gclid": "EAIaIQobChMI...",
    "fbclid": "IwAR3x...",
    "first_touch_source": "google",
    "first_touch_medium": "cpc",
    "first_touch_campaign": "black_friday_2026"
  }
}
```

### One conversion per transaction

To send a conversion to Meta Conversions API at most once per transaction, even if the **purchase** event arrives more than once: on the first firing, write a document to the `capping` collection with the transaction key, such as `cap_` plus the order ID. Before each firing, read that key. If the document already exists, do not fire again.

### Real-time data enrichment

When an **add_to_cart** event arrives, sGTM reads the customer's segment (vip, returning or new), LTV and loyalty tier from Wascer DB. This data is added as parameters to the event sent to Google Analytics 4 and Meta Conversions API, with no calls to CRMs or CDPs.

## Availability

Wascer DB comes with paid plans, from **Starter** up, with no per-operation charge. It is not available on the Start plan. Compare plans on the [pricing page](https://wascer.com/be-fr/pricing). For higher volumes or a custom implementation, [talk to the sales team](https://wascer.com/be-fr/contact-sales).

Source: https://wascer.com/helpdesk/wascer-db/wascer-db-doc
