# Move from Google Analytics to Checkend

> Replace Google Analytics 4 with Checkend. Run both for a period, convert your gtag events, and remove gtag.js or the tag in Google Tag Manager.

> **Caution**
> Your Google Analytics history does not move. Checkend imports only the raw events of Plausible Community Edition. Keep your Google Analytics property for as long as you need its data.

On a standard property, the [data retention setting](https://support.google.com/analytics/answer/7667196) (2 or 14 months) applies to explorations and funnel reports, not to the standard aggregated reports.

## Run both for a period

You can put both scripts on your site for some weeks. Then compare the numbers before you remove Google Analytics.

Expect different numbers:

- Google Analytics [distinguishes users with the `_ga` cookie](https://support.google.com/analytics/answer/11397207), which lasts 2 years by default. Checkend gives a visitor a new number each day.
- A person who returns on three days counts as three visitors in Checkend, in a longer period.
- Google Analytics can [withhold rows](https://support.google.com/analytics/answer/9383630) in reports with demographic or search query data when there are not enough users.
- Checkend does not count some visits, for example bots that it recognizes. See [Visits that are not counted](/docs/install.md#visits-that-are-not-counted).

## Replace the script

1. Add the site in Checkend.
2. Add the Checkend snippet to the `<head>` of every page, as [Install the analytics script](/docs/install.md) shows.
3. Convert your Google Analytics events, as [Convert the events](#convert-the-events) shows.
4. Remove Google Analytics with gtag.js or with Google Tag Manager, as the next sections show.
5. Deploy your site.
6. Open your site.
7. Open the dashboard of the site in Checkend and select the period realtime. Your visit shows there.

### Remove gtag.js

> **Caution**
> A call to `gtag()` without the Google tag snippet gives a JavaScript error. Replace or remove each `gtag()` call before you remove the snippet.

1. Replace or remove each `gtag()` call in your code.
2. Find the [Google tag](https://developers.google.com/tag-platform/gtagjs/install) in the `<head>` of your pages. It has a script from `www.googletagmanager.com` and a script that defines `gtag()`.
3. Remove both scripts.

### Remove the tags in Google Tag Manager

Do this when Google Tag Manager loads Google Analytics. Keep the Tag Manager snippet if other tags use it.

1. In Tag Manager, click **Tags**.
2. Open a tag that sends data to Google Analytics, for example the Google tag with your measurement ID (`G-`).
3. Click the 3-dot icon and select **Pause**, as [Pause tags](https://support.google.com/tagmanager/answer/7679308) shows.
4. Click **Save**.
5. Do steps 2 to 4 again for each other Google Analytics tag.
6. Click **Submit**, then **Publish**, as [Publishing, versions, and approvals](https://support.google.com/tagmanager/answer/6107163) shows.

A paused tag does not send data. You can unpause it if you need it again.

If Tag Manager also adds the Checkend snippet, the key is not in the HTML of your home page. Verify the domain with a DNS record, as [Verify the domain](/docs/install.md#verify-the-domain) shows.

## Convert the events

> **Caution**
> Do not put names, email addresses or other personal data in an event name or a property.

There are no goals to set up. An event shows with its properties when it arrives.

```js
// Google Analytics
gtag('event', 'sign_up', { method: 'Google' });
gtag('event', 'generate_lead', { lead_source: 'Trade show', value: 50, currency: 'USD' });
gtag('event', 'purchase', { transaction_id: 'T_12345', value: 30.03, currency: 'USD', items: [/* … */] });

// Checkend
window.checkend('Sign Up', { props: { method: 'Google' } });
window.checkend('Generate Lead', { props: { lead_source: 'Trade show' } });
window.checkend('Purchase', { props: { value: '30.03', currency: 'USD' } });
```

- Checkend stores each value as text. The docs describe no revenue report. A purchase is an event with properties.
- Give each property one value. Leave out lists, for example `items`.
- Keep in the [limits](/docs/events.md#limits): 30 properties in one event, and 2,000 bytes for a property value.
- To send events before the script loads, add the queue that [Send custom events](/docs/events.md) shows.

The names and parameters of the Google Analytics events are in [Recommended events](https://developers.google.com/analytics/devguides/collection/ga4/reference/events).

## Google Analytics 4 and Checkend

| Google Analytics 4 | Checkend |
| --- | --- |
| [`gtag('event', 'name', { … })`](https://developers.google.com/analytics/devguides/collection/ga4/events) | `window.checkend('Name', { props: { … } })`. See [Send custom events](/docs/events.md). |
| [Key events](https://support.google.com/analytics/answer/13128484), marked in Admin | No goals to set up. Each event shows when it arrives. |
| [Custom dimensions](https://support.google.com/analytics/answer/10075209) for event parameters | Each event shows with its properties, with no setup. You can filter by a property. |
| [UTM parameters](https://support.google.com/analytics/answer/10917952) | Checkend reads `utm_source`, `utm_medium`, `utm_campaign`, `utm_content` and `utm_term`. It also reads `ref` and `source` when there is no `utm_source`. |
| [Funnels](https://support.google.com/analytics/answer/9327974) of up to 10 steps | Funnels of 2 to 8 steps from pages or events, in order and within 7 days. See [Read the dashboard](/docs/dashboard.md#funnels). |
| [User explorer](https://support.google.com/analytics/answer/9283607) | No view of one person. A visitor gets a new number each day. |
| [Audiences](https://support.google.com/analytics/answer/9267572) and the [Google Ads link](https://support.google.com/analytics/answer/9379420) | No ad integration and no audiences. |
| [BigQuery export](https://support.google.com/analytics/answer/9358801) | The [HTTP API](/docs/api.md) gives metrics by up to 3 dimensions. You can [export the raw events](/docs/account.md#export-your-data) as CSV or Parquet files, in the app or with the API. |

## Consent and privacy

The Checkend script sets no cookies and stores nothing in the browser. Whether you need consent depends on your site and your law. Ask your lawyer.

[What an event holds](/docs/privacy.md) lists the data that Checkend stores. Review your cookie list and your privacy policy after you remove Google Analytics.

## Compare

[Compare the two tools](/compare/google-analytics/): cookies, data retention, events, funnels and price, with links to Google's own docs.

## Prompt for a coding agent

```text
Replace Google Analytics with Checkend web analytics in this project.
1. Ask me for the snippet of the site from my Checkend account. Do not make up the site key.
2. Add the snippet one time, so that it is in the head of every page.
3. Find each gtag('event', ...) call. Replace it with window.checkend('Event Name', { props: { key: 'value' } }). Use Title Case for the name.
4. Do not put names, email addresses or other personal data in the name or the properties.
5. Remove the other gtag() calls and the Google tag snippet. If Google Tag Manager loads Google Analytics, tell me. Do not remove the Tag Manager snippet.
6. Show me the change. Stop before you deploy and wait for my approval.
```
