# Google Analytics

### Step 1: Add Code to Your Website&#x20;

To send the Zipy session URL to Google Analytics, add the following code snippet to your website. This code uses the gtag.js API to send a custom event with the event name 'zipy\_event'. The Zipy session URL is included as a parameter with the key 'zipy\_session\_url' in the event payload.

```javascript
gtag('event', 'zipy_event', {
  'zipy_session_url': window.zipy.getCurrentSessionURL()
});
```

### Step 2: Trigger the Event on User Action (Optional)&#x20;

If you want to send the Zipy session URL based on a specific user action, such as a button click or when an error occurs, you can add additional JavaScript code to trigger the event. For example, to send the Zipy session URL when an error occurs, you can use the `window.onerror` event handler:

```javascript
window.onerror = (error) => {
  gtag('event', 'zipy_event', {
    'error': error,
    'zipy_session_url': window.zipy.getCurrentSessionURL()
  });
};
```

### Step 3: Add zipy\_session\_url in Custom Dimensions

Go to Admin> Property Settings> Data Display>Custom Definitions> Create Custom Dimension as shown in the image below.&#x20;

<figure><img src="/files/ui8OnU698xkgPQtG7E6r" alt=""><figcaption></figcaption></figure>

### Step 4: Verify Event in Google Analytics&#x20;

After completing the integration steps, you can verify the event in your Google Analytics dashboard. Log in to your Google Analytics account, navigate to the appropriate property, and go to the "Events" section. You should see the Zipy session URL data associated with the event, providing insights into session replay.

<figure><img src="/files/Yxvfet7pLmL3Un3EziR1" alt=""><figcaption></figcaption></figure>

For more information on sending events to Google Analytics and analyzing event data, you can refer to the following link: [Link to Google Analytics documentation on sending events](https://developers.google.com/analytics/devguides/collection/gtagjs/events)


---

# 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://docs.zipy.ai/integration/google-analytics.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.
