> ## Documentation Index
> Fetch the complete documentation index at: https://docs.claimr.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics integration

> Integrate the Claimr widget with Google Analytics 4 using the data-ga4 embed script attribute or a URL parameter.

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.

<Steps>
  <Step title="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).
  </Step>

  <Step title="Modify your Claimr embed script">
    Add the `data-ga4` attribute to your Claimr script tag, replacing `"GA4-KEY"` with your actual Measurement ID:

    ```html theme={"dark"}
    <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.
  </Step>
</Steps>

## 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 theme={"dark"}
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.
