# Google Analytics Integration (GA4)

## Enable Google Analytics integration

![](https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jkFgNo4lpUof35gvS%2F-M1a043fpNqhthpUAI-Z%2F-M1a4O9Xi4PWB8FDgN3A%2Fimage.png?alt=media\&token=a18c2f6a-87bc-4d8e-b764-9043b80b2ae5)

Simply go to the **Analytics Integration** plugin submenu to turn on the Analytics integration.&#x20;

* [**Events Tracking**](https://documentation.ajaxsearchpro.com/analytics-integration/events-tracking)  - Allows you tracking all sorts of events, such as input focus, live search, facet changes etc.. with customizable parameters

## Tracking ID

While the plugin tries to get your tracking code automatically, it is recommended to enter your tracking code anyways. If you use **Google Tag Manager**, then this is **not required**.

<figure><img src="https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2FGsK9JJZif9vT2yLG9QPR%2Fimage.png?alt=media&#x26;token=93164ec4-4ea3-409b-8d4e-be9037396df5" alt=""><figcaption></figcaption></figure>

## Events Tracking

In this mode, analytics event triggers can be enabled for specific search events. To enable a an event trigger, click on the "On/Off" button on the desired section.

![](https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jkFgNo4lpUof35gvS%2F-M1j08WecDJL6TY8zzPM%2F-M1j1De4NcTob1MtC41b%2Fimage.png?alt=media\&token=4ca98422-3c31-4ef9-bb12-6912fe5c5cef)

For each event, you can set up the Event Action, Label, Category and Event value. Please check the [About Events](https://support.google.com/analytics/answer/1033068?hl=en) documentation to understand what they are.

### Usable variables

Each event has a list of variables, that can be used within that event fields.

![](https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9jkFgNo4lpUof35gvS%2F-M1j08WecDJL6TY8zzPM%2F-M1j2D5YxQu9PsAzyIes%2Fimage.png?alt=media\&token=74bf73ce-c307-4704-9230-006b8c582c55)

The variables are replaced with the corresponding values:

* **{search\_id}** - The search instance ID
* **{search\_name}** - The search instance name
* **{phrase}** - The search phrase entered
* **{results\_count}** - The number of results ("unknown", when not available)
* **{option\_name}** - The facet option legend name, when the user clicks on a facet
* **{option\_value}** - The facet option value or label name, when the user clicks on a facet
* **{result\_title}** - The result title, when the user clicks on a live result
* **{result\_url}** - The reulst URL, when the user clicks on a live result

After a successful integration, the events will start showing up on the Google Analitycs real time Events panel, as well as in the events section under the **Engagement** panel **after a few days**.

![GA4 Realtime events Ajax Search Pro](https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2F4ot3fqlyp15pZOwRgIAS%2Fimage.png?alt=media\&token=76573b18-990b-4393-bfde-b90449100218)![GA4 Events Ajax Search Pro](https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2FzTsExTEsAtnZZVFkaaFR%2Fimage.png?alt=media\&token=96fb41ce-0cce-4a31-adf1-32443da77933)

## Matomo analytics integration

While Matomo is not integrated to the core of the plugin, it is still possible to enable events and site search tracking with Matomo. For details please check the [Matomo Analytics Integration](https://knowledgebase.ajaxsearchpro.com/miscellaneous/other/matomo-analytics-tracking-integration) knowledge base.
