> For the complete documentation index, see [llms.txt](https://smartui-docs.pixelperfectstudio.mx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smartui-docs.pixelperfectstudio.mx/miscellaneous-addons/google-analytics-4/getting-started.md).

# Getting Started

Configuring GA4 and Sending Events

Welcome to this beginner-friendly guide on setting up the **Google Analytics 4 (GA4) plugin for Construct 3**! This tutorial will walk you through all the steps to integrate GA4 into your Construct 3 project, from obtaining your GA4 ID to tracking custom events. You’ll also learn important details about privacy considerations and how long it takes for your data to show up in Google Analytics.

{% hint style="danger" %} <mark style="color:red;">**Please not that GA4 collects data automatically. Refer to the**</mark> [<mark style="color:red;">**official documentation**</mark>](https://support.google.com/analytics/answer/9234069?hl=en\&sjid=2816563681640243339-NC) <mark style="color:red;">**for more information. For this reason, you must be compliant at all times with privacy policies and data protection regulations for users on every country where you collect data.**</mark>
{% endhint %}

## **Step 1: Setting Up Google Analytics 4 (GA4) Account**

Before you can start tracking your game with the GA4 plugin in Construct 3, you need to set up a GA4 account and get your **GA4 Measurement ID** (also known as the GTAG ID). Here’s how you can do it:

1. **Go to the Google Analytics website**: Open [Google Analytics](https://analytics.google.com/) and sign in with your Google account. If you don’t have a Google Analytics account yet, you'll need to create one.
2. **Create a Property**:

   * Once logged in, click on **Admin** (the gear icon at the bottom left).

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2Fyrc0uWmSnCfTICp8FDe3%2Fimage.png?alt=media&amp;token=b775f544-7459-4205-81aa-c53c0b29c008" alt="" width="563"><figcaption></figcaption></figure>

   * In the "Account" column, select the account where you want to add the property (or create a new account).
   * In the "Property" column, click **+ Create Property**.

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FqU6M4UKDKRlwGqprKA5B%2Fimage.png?alt=media&amp;token=d3374742-0185-49bd-9edd-8c72aaeac982" alt="" width="563"><figcaption></figcaption></figure>

   * Choose **Web** as the platform for your property, and fill in the details like the name of your game, the website URL (if applicable), and your country.
   * Click **Create**.
3. **Obtain the GA4 Measurement ID**:

   * After creating your property, you’ll see a **Data Stream** option. Select **Web** for a web-based game (or the correct platform).

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FepFfXo76WsWGzjQc5lIP%2Fimage.png?alt=media&amp;token=560ecf3b-e6d6-43bc-b2b1-58415372da1b" alt="" width="563"><figcaption></figcaption></figure>

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2F9YRdiaR0EJvfjviAF7tf%2Fimage.png?alt=media&amp;token=cda2a48f-1c51-4791-a372-d091ca8e5752" alt="" width="563"><figcaption></figcaption></figure>

   * Under the Web stream details, you will see the **Measurement ID** at the top (it starts with "G-" followed by a series of numbers and letters). Copy this ID as you’ll need it to set up the plugin in Construct 3.

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FOnMXLF5DbsvNyGqv1e1T%2Fimage.png?alt=media&amp;token=240c2e52-0fb2-4070-a0eb-104342274001" alt=""><figcaption></figcaption></figure>

***

## **Step 2: Installing the GA4 Plugin in Construct 3**

Now that you have your GA4 Measurement ID, let’s set up the plugin in Construct 3:

1. [**Download** ](https://store.pixelperfectstudio.mx/product/ga4/)**and Install the GA4 Plugin**:
   * Go to the **Construct 3 Plugin Store** and search for the **Google Analytics 4 Plugin**.
   * Download and install the plugin into your Construct 3 project.
2. **Add the Plugin to Your Project**:

   * Open your Construct 3 project.
   * Add the GA4 plugin to your project.

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FbehE39XR9C1kJ49qQTVE%2Fimage.png?alt=media&amp;token=ed376055-350c-4fdc-9da6-f438794c8a11" alt="" width="298"><figcaption></figcaption></figure>

   * Set the **GA4 Measurement ID** (the GTAG ID you copied earlier), and set the initialization type to Auto.  If the property is valid, the plugin will automatically initialize the analytics engine.

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2Fo1CCJmlTluoQESpIPY2g%2Fimage.png?alt=media&amp;token=c11746a7-a48f-4ba1-8ebc-429f9b41e576" alt=""><figcaption><p>Set Google Analytics 4 property ID to start collecting data.</p></figcaption></figure>

{% hint style="info" %} <mark style="color:blue;">**Manual initialization**</mark> by using the **`Initialize`** action is also available, as well as additional options for advanced users. However, the steps described in this tutorial should suffice most of your basic needs to start sending events and tracking your game's performance. <mark style="color:blue;">**You don't have to call Initialize if you followed this tutorial steps.**</mark>
{% endhint %}

3. **Testing the Plugin**:

* Once you’ve added the GA4 plugin and configured the Measurement ID, test your game to ensure that the plugin is sending data to your GA4 account. You can do this by checking the **Realtime** section in Google Analytics to see if the visits are being tracked as soon as you play the game.

{% hint style="warning" %}
Please note that on brand new properties, <mark style="color:orange;">**data collected will reflect up to 48 hours later.**</mark> Refer to the [official GA4 ](https://support.google.com/analytics/answer/11198161?hl=en)documentation for more information.
{% endhint %}

<figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2Ff1Fpi7hmPfyr8KhJTlTp%2Fimage.png?alt=media&amp;token=91c8cdf0-9a57-41af-9b50-9471443fd209" alt=""><figcaption><p>Report Snapshot</p></figcaption></figure>

<figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2Fg9LG8r2buZTaamnGgyWj%2Fimage.png?alt=media&amp;token=05b8bd9b-049d-4be7-ac87-b91b898cd4a6" alt=""><figcaption><p>Realtime Overview</p></figcaption></figure>

***

## **Step 3: Setting Up Events in Google Analytics 4**

Now, let's configure custom events in your game to track specific player actions, such as completing a level, making a purchase, or clicking a button. Here’s how you can set up events:

1. **Create Events in Construct 3**:

   * Open the **Event Sheet** in your Construct 3 project.
   * Add a **`Send Event`** like “button\_clicked”, " or “player\_dead”.&#x20;
     * Event names are case sensitive. For example, `my_event` and `My_Event` are distinct events.
     * Event names can include English and non-English words and letters.
     * Do not use reserved prefixes and event names.
     * Event names must start with a letter. Use only letters, numbers, and underscores. Don't use spaces.

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FJmz1zz9TCwiIE6YT5q9W%2Fimage.png?alt=media&amp;token=91c0d497-55cd-42e8-9880-01abbf469eed" alt="" width="426"><figcaption></figcaption></figure>

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2F3dmlTWJaBZgzmuIEcG7l%2Fimage.png?alt=media&amp;token=50785e72-5097-4693-8bbb-865c4bd7b91f" alt="" width="375"><figcaption></figcaption></figure>

   * **`Send event`** will automatically queue the information for further processing. GA4 will determine the best moment to report it.

   <figure><img src="https://3242409510-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9bZkqK9vYvPkvVDUO4Tp%2Fuploads%2FgOsiouoFm6qPUpNAwcHt%2Fimage.png?alt=media&amp;token=a6234400-acf6-49ef-8bae-08dfeb9090a7" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %} <mark style="color:red;">**Please not that GA4 collects data automatically. Refer to the**</mark> [<mark style="color:red;">**official documentation**</mark>](https://support.google.com/analytics/answer/9234069?hl=en\&sjid=2816563681640243339-NC) <mark style="color:red;">**for more information. For this reason, you must be compliant at all times with privacy policies and data protection regulations for users on every country where you collect data.**</mark>
{% endhint %}

***

## **Step 4: Understanding GA4 Event Delays and Privacy Considerations**

### **Event Delays in GA4**

When you first start using Google Analytics 4, it’s important to know that there may be a delay in seeing your event data. **GA4 may take up to 48 hours** for the data to appear, especially if the property is new. This is a normal part of Google Analytics data processing, and it’s something to be aware of while setting up and testing your events.

### **Privacy Considerations**

As a game developer using the GA4 plugin, it’s important to understand that you are responsible for **compliance with privacy laws** and **data protection regulations** in the countries where your users are located. Here are a few things to keep in mind:

1. **Personal Data**: Google Analytics does not collect personally identifiable information (PII) unless explicitly configured to do so, but it is still important to review the data being tracked and ensure it doesn’t violate privacy laws.
2. **Data Collection Compliance**: You should be aware of and comply with data protection laws such as:
   * **GDPR (General Data Protection Regulation)** in the European Union.
   * **CCPA (California Consumer Privacy Act)** in California, USA.
   * Other regional privacy laws that may apply depending on your users’ location.
3. **User Consent**: Depending on your region and the data you are collecting, you may need to display a **cookie consent banner** to your users. Make sure users are informed and give consent before you track their data.
4. **Data Retention**: Google Analytics 4 offers various settings for how long data is retained. You should review these settings to ensure they align with your game’s privacy policies.

Remember to keep privacy and data protection in mind, as you are responsible for ensuring compliance with applicable laws. Enjoy the power of data-driven game development with **GA4**!
