> For the complete documentation index, see [llms.txt](https://docs.claimr.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.claimr.io/widget/claimr-widget-integrations/google-analytics-integration.md).

# Google Analytics integration

Claimr supports two methods for integrating with GA4:

## **Method 1: Using the `data-ga4` attribute in the embed script**

This is the recommended method for most implementations. You add your GA Measurement ID (which looks like `G-XXXXXXXXXX` or `GA4-KEY`) directly to the claimr embed script.

1. **Find your GA measurement ID:**

   * Log in to your Google Analytics account.
   * Go to the Admin section.
   * In the Property column, select your GA property.
   * Click on "Data streams," then select your web data stream.
   * Your Measurement ID will be displayed at the top. It typically starts with "G-".

   For detailed instructions, see Google's documentation: [Find your Google tag ID](https://support.google.com/analytics/answer/9539598?hl=uk)
2. **Modify your claimr embed script:** Add the `data-ga4` attribute to your claimr script tag, replacing `"GA4-KEY"` with your actual Measurement ID:

   ```html
   <script src="https://widgets.claimr.io/claimr.min.js"
       id="claimr-script"
       data-ga4="G-XXXXXXXXXX"  data-organization="ORGANIZATION_NAME"
       data-campaign="CAMPAIGN_NAME"
       data-autoresize="true"
       data-container="CLAIMR_CONTAINER_ID">
   </script>
   ```

   Make sure you replace `ORGANIZATION_NAME`, `CAMPAIGN_NAME`, and `CLAIMR_CONTAINER_ID` with your actual values.

## **Method 2: Passing the GA4 Key in the URL**

This method is useful if you cannot directly modify the embed script, or if you need to dynamically change the GA4 Measurement ID.

1. **Find your GA4 measurement ID:** (Same as Method 1)
2. **Construct the URL:**  Add the `ga4` parameter to your claimr campaign URL, replacing `"GA4-KEY"` with your actual Measurement ID:

   ```html
   https://campaign?ga4=GA4-KEY
   ```

## **Verifying GA4 integration**

After implementing either method, you should start seeing events from your claimr widget in your GA4 Realtime reports. It may take a few minutes for data to appear. You can use the Realtime view to test if events are being tracked correctly.


---

# 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 dynamically by asking a question.

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

```
GET https://docs.claimr.io/widget/claimr-widget-integrations/google-analytics-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
