# Google Analytics 4 (GA4) Integration Guide

## How to Integrate with Google Analytics 4 (GA4)

Google Analytics 4 (GA4) is a next-generation tool that collects and analyzes visitor data from websites and apps. By integrating Ptengine with GA4, you can send interaction data such as popups, page edits, and A/B tests to GA4, enabling more detailed analysis. Below, we explain the integration method in detail.

## Prerequisites for Integration

GA4 code is already installed on your website

If using Google Tag Manager (GTM), place the Ptengine tag after the GA code.

Once GA4 integration is configured, you do not need to repeat the setup for each new Experience thereafter.

Not all data integrations are supported. Redirect-type Experience interaction data transmission is not supported.

## How to Enable GA4 Integration in Ptengine

To enable GA4 integration, follow these steps:

Log in and access the relevant account.

Click the ⚙ in the top right corner and click "Integration" in the displayed menu. It will look like the figure below: On this page, profile-level push activation is provided, and enabling it will apply to all subsequent Experiences by default.

Click the Google Analytics 4 card and expand it as shown in the figure below, then click "Enable Immediately".

The operations within Ptengine are now complete.

## Setting Up Experience Variables as Custom Dimensions in GA4

After enabling GA4 integration in Ptengine, you need to map Experience variables to GA4. This allows you to send experiment data to GA4. Follow the steps below:

Sign in to your GA4 account.

From the main menu panel on the left, go to \[Administration] → \[Custom Definitions] → \[Create Custom Dimension]. The operation screen will look like this:

Create a custom dimension in the new custom dimension popup window.

💡Custom Dimension Explanation: **Dimension Name** Enter the name of the custom dimension as the name of the Experience variable.

```
**Scope**
Specify the scope as "Event".

**Description**
Enter a description of the custom dimension.

**Event Parameter**
You need to create two custom dimensions respectively to paste the following related experience information into event parameters. The following information represents the name of the experience and the name of the version.
• pt_experience_name
• pt_experience_version_name

In GA4, you can select from a dropdown, but you can also enter directly or copy and paste. The official GA4 documentation is [here]().
```

### Events That Can Be Sent to GA4

In Advanced mode, there may be multiple popups. To ensure the accuracy of A/B tests, in this mode only one event package can be sent per Page View Experience. (pt\_experience\_impression, pt\_experience\_close, pt\_experience\_click)

## Validating the Integration Configuration

After mapping the Experience variables in GA4, you can verify that data is being sent correctly from Ptengine to GA4 by validating network requests. Follow the steps below:

On the Experience popup page, right-click and select "Inspect Element".

Select the "Network" tab and search for "analytics.google.com" to filter GA4 network requests.

If you can see events such as "pt\_experience\_impression" displayed, it confirms that Ptengine is successfully sending events to GA4.

Note: Since GA4 data processing takes time, it may take 24-48 hours after enabling integration before data appears in GA4. Please wait.

## About GA4 Integration Issues

If you installed using "Google tag" with Google Tag Manager (GTM), GA4 may not be able to collect data from Ptengine.

### **Solution**

To ensure smooth integration between Ptengine and GA4, place the following tag **before the Ptengine base tag**.

```
<script>
var ptTimer = setInterval(function(){
    if(dataLayer){
        clearInterval(ptTimer);
        if (typeof(gtag) === 'undefined') { 
                    gtag = function() { dataLayer.push(arguments); };
                    gtag('js', new Date());
                    gtag('config', 'G- set your GA4 sid');
                }
    }
},500)
</script>
```

※ You need to replace "G- set your GA4 sid" in the code with your site's GA4 sid.

🔰How to Get GA4 sid

1. Enter the GA4 admin screen.
2. Press the "Data Stream" button under "Data Collection and Modification".
3. Select the specified data stream and confirm the "Measurement ID".

After confirming the "Measurement ID", replace "G- set your GA4 sid" above with the "Measurement ID", and the gtag configuration is complete.

### Creating GA4 Data Exploration and Adding Segments

Go to "Exploration" and select a type of data exploration or start from a blank state.

In the "Variables" panel on the left, click the plus icon next to "Segment". On the "Create New Segment" page, click "User Segment".

Enter the name of the segment. For example, a specific experience or version name.

Expand the "Add Description" dropdown, click "Event", and select "pt\_experience\_impression" or "pt\_experience\_click" (varies depending on the segment you want to create).

Click the "Add Parameter" dropdown.

Click "Custom" and select pt\_experience\_name.

Select or specify the specific experience name for which you want to create this segment.

If you want to specify a specific version, click the "Add Parameter" dropdown again, add another parameter, click pt\_experience\_version\_name, and select or specify the specific version name for which you want to create this segment.

Click "Save" and you can then use the segment in reports.

### Creating GA4 Audiences

Go to "Administration", select "Audience", and click "Audience".

On the "Create Audience" screen, expand the "Add New Condition" dropdown, click "Event", and select **pt\_experience\_impression** or **pt\_experience\_click** (varies depending on the audience you want to create). For example, if you want to create an audience for users who were shown an exit intent popup, select the event **pt\_experience\_impression**, click "Add Parameter", select **pt\_experience\_name**, set the condition to "contains", and enter the "experience name".

If you cannot find the event or event property in the dropdown, it's possible that the data has not yet been synchronized to GA4. In that case, you can create a new event by clicking "Create Event" or "Register New Definition".

Click "Save" to save the audience. Usually, it may take 24-48 hours for data to be reflected in the audience.

After creating the audience, you can use it in reports.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helps.ptengine.com/en/integrations/ga4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
