> For the complete documentation index, see [llms.txt](https://docs.jentis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jentis.com/use-cases-and-tutorials/persist-user-data-for-google-ads-enhanced-conversions.md).

# Persist User Data for Google Ads Enhanced Conversions

In many tracking scenarios, PII (like a hashed email) or other crucial data (like a networks click ID) is only available during a specific event (e.g., on landing page or on registration). To use this data for a later conversion event in any connector with JENTIS is a common use case.

In this guide we will describe this use case on example of Google Ads Enhanced Conversions, where the user provided data must be persisted on the server. Which improves data privacy and security. All implemented with your JENTIS Server Side tag management solution.

### 1. Persisting Data with Server-Side Storage

To store a value across a session, you must create a **Server-Side JS Code** variable.

In our example use case we assume an email-address value is available with a certain event. On this occasion it is observed and persisted server side, making it available for later events in a users session.

#### The Logic

The variable should perform three steps:

1. **Check** if the value exists in the current event (using this.getFrontendVariable).
2. **Write** the value to storage if it is present.
3. **Read** and return the value from storage if it is not in the current event.

Create a new server-side variable of type "Server Side Javascript Code". Use the following code to store and return the latest email-value from storage.

<figure><img src="https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FdaPynHveONlWcRTwoniU%2Fimage.png?alt=media&amp;token=dc25be03-1128-4fbf-8346-a362482e3ae5" alt=""><figcaption></figcaption></figure>

#### Code Example

```javascript
async function cstm_persisted_user_email() {
  // 1. Try to get the email from the current event
  const email = this.getFrontendVariable("datplayer_email_hashed");

  // 2. If found, save it to session storage (valid for 30 mins)
  if (email) {
    this.userStorage.write("persisted_email", email, Date.now() + 1800000);
    return email;
  }

  // 3. If not in current event, retrieve from storage
  const storedEmail = await this.userStorage.read("persisted_email");
  return storedEmail || null;
}
```

#### Storage Types

You can use either the `userStorage` (as in the example) or a tool instance storage. Here are the key differences:

* `userStorage` will store the value in context of the connector-instance you configured, ie. with the Google Ads configuration; other connectors can't access the value. This is the most common use case. More infos on [user storage](/developer-guide/variables/server-side-variables/public-function-scope/user-storage-per-tool-instance.md).
* `toolInstanceStorage` will store the value in context of the connector-instance the same but accessible to all events from all website visitors; ideally to store shared connector-level information that is shared across all sessions on your website. Do not use it for user-related information. More infos on [tool instance storage](/developer-guide/variables/server-side-variables/public-function-scope/tool-instance-level-storage.md).

### 2. Configuring Google Ads Enhanced Conversions

Once the variable is created, follow these steps in the JENTIS DCP:

1. Navigate to **JENTIS Tag Manager** -> **Tags**.
2. Configure a new tag with template "Campaign Linker" which will execute with the event where the email is observed. This is important to ingest the information into the storage.
3. We will override the general Campaign Linking purpose of this tag (which does the same for `gclid` by default) now to store the email-information. You can select the newly created email-variable instead of the GCLID Variable:\
   ![](https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FIDqorWM0jmOx0JjX2v1v%2Fimage.png?alt=media\&token=40f167ba-0710-4caa-8056-78f35dcf6373)\
   Please note: This "Campaign Linker" tag is a vehicle to execute the variable on the right event. It will not send any data to Google yet, only execute the variables you configured with it.
4. Trigger this tag with your event where the email value is observed.

Now when this tag executes the variable will read the email and store it on the server.

To finish this configuration you must also make use of that value within a conversion tag. Simply configure the same email-variable in the "Enhanced Conversion" tab.

![](https://2315305008-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy15ncufYr341K5U8q6Of%2Fuploads%2FHGzx27K7kFXw2TFi4rjP%2Fimage.png?alt=media\&token=e28a1671-6b6a-4588-b799-32b261e895d0)&#x20;

Now the conversion will refer to the previously stored information.

### 3. Important Considerations

* **Server-Side Only**: Data stored via this.storage is only accessible to JENTIS server-side tags. Client-side tags (like a standard GTAG implementation) cannot access this server-side storage.
* **Hashing**: Ensure the data is already hashed (SHA256) before sending it to Google, or use the JENTIS ga\_sha256() helper function if the input is clear text. [Here is a guide on enhanced conversion data hashing with Google Ads](/data-activation/connectors/google-ads/google-ads-enhanced-conversion-configuration-guide.md).

### FAQ

* **How long does the data stay in storage?** You define the expiration in the write function (e.g., Date.now() + duration\_in\_ms).
* **Can I use this for other connectors?** Yes, if you use [Global User Storage](/developer-guide/variables/server-side-variables/public-function-scope/global-user-storage.md), the data is available to all server-side connectors in that session.


---

# 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.jentis.com/use-cases-and-tutorials/persist-user-data-for-google-ads-enhanced-conversions.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.
