# Tracking with Google Site Tag (gtag.js)

## Google Tag Tracking code installation

For events tracking the [GA4 gtag.js](https://support.google.com/analytics/answer/9304153) must be installed for your webpage. For more information what the gtag is check the [Google Tag](https://developers.google.com/tag-platform/gtagjs) documentation.

The tracking code should look something like this, and should be in your site header:

```javascript
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1234567890"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-1234567890');
</script>
```

After the tag installation see the [Events Tracking](/analytics-integration.md#events-tracking) to setup the desired events to track.


---

# 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://documentation.ajaxsearchpro.com/analytics-integration/events-tracking.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.
