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

# Google Analytics

Set up Google Analytics on your RaffleX site so you can see where visitors come from, which pages they visit and which marketing actually brings in ticket sales.

Google Analytics is a free tool from Google that shows you how people use your website. Once it is connected you can see how many people visit, where they came from (Facebook, Google, an email, a TikTok video), which competitions they look at, and how many go on to buy.

RaffleX does not have a dedicated Google Analytics box. Instead, you paste the tracking code Google gives you (called the **Google tag**) into the **Header Code** field on your **Advanced** settings page. From then on it loads on every page of your site, and RaffleX automatically sends your completed sales to Google as well.

This guide walks you through the whole process, from creating a Google Analytics account to checking that data is arriving.

{% hint style="info" %}
**Before you start**, you need a Google account. If you do not have one, create one at [accounts.google.com](https://accounts.google.com). You can use an existing email address or set up a new Gmail account. Many operators create a dedicated business Google account so the analytics are not tied to one person's personal email.
{% endhint %}

***

### Step 1. Create your Google Analytics account and property

Google calls each website you track a **property**. Your property sits inside an **account**, and one account can hold several properties if you run more than one site.

1. Go to [Google Analytics](https://analytics.google.com/) and sign in with your Google account.
2. Click **Start measuring**.
3. Enter an **Account name**. This is just for you, so your business name works well.
4. Leave the data sharing options as they are (or untick any you are not comfortable with) and click **Next**.
5. Enter a **Property name**, for example your raffle site's name.
6. Set the **Reporting time zone** to your own country (for example United Kingdom) and the **Currency** to match your site (**British Pound** or **Euro**). Click **Next**.
7. Choose your **Industry category** and **Business size**, then click **Next**.
8. Choose your **business objectives**. If you are unsure, pick the options about understanding web traffic and driving online sales. Click **Create** and accept Google's terms.

{% hint style="warning" %}
**Match the currency to your site.** RaffleX sends every sale to Google in the currency set on your site (GBP or EUR). If your Google Analytics property is set to a different currency, Google converts the figures and your revenue may not match your own sales reports. You can check your site's currency in the admin panel under **Settings**, then **Checkout**. See [Order and Cart Settings](/additional-settings/order-and-cart-settings.md).
{% endhint %}

Google changes its setup screens from time to time, so the exact wording or order you see may be slightly different. The information it asks for stays the same.

***

### Step 2. Set up a web data stream

A **data stream** is the connection between your property and your website.

1. When Google asks you to choose a platform, click **Web**.
2. Enter your **Website URL**, for example `www.yourrafflesite.co.uk`. Google adds the `https://` part for you.
3. Enter a **Stream name**, such as "Main website".
4. Leave **Enhanced measurement** switched on. This automatically records useful extras such as scrolls and outbound link clicks.
5. Click **Create stream** (on some screens this is **Create & continue**).

Google now shows your stream details, including a **Measurement ID** that starts with **G-** (for example `G-AB12CD34EF`). You do not need to copy this on its own, but it is useful to know which property a tag belongs to.

***

### Step 3. Copy your Google tag

1. On the stream details screen, look for **View tag instructions** (it may also appear automatically as **Installation instructions**).
2. Choose **Install manually**.
3. Click the copy button next to the code. It looks similar to this, with your own Measurement ID in place of `G-XXXXXXXXXX`:

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

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

{% hint style="warning" %}
Always copy the tag from your own Google Analytics account. The example above will not work on your site, because it does not contain your real Measurement ID.
{% endhint %}

***

### Step 4. Add the Google tag to your RaffleX site

1. Log into your RaffleX **admin panel**.
2. In the left-hand menu, find the **Content** group and click **Settings**.
3. In the Settings side menu, click **Advanced**. The page title reads **Advanced & Configuration**.
4. Scroll to the **Code Injection** section.
5. Click inside the **Header Code** box. It is an inline code editor, so you paste straight into it. There is no separate **Edit** button.
6. If the box already contains code, click at the very end of it and press **Enter** to start a new line. Then paste your Google tag. Do not remove existing code unless you know it is no longer needed.
7. Click **Save Settings** at the bottom of the page (or press **Cmd + S** on a Mac, **Ctrl + S** on Windows). A green message reading "Advanced settings saved successfully" confirms the save.

Your tag is now live on every page of your site, including your checkout and the **Order Successful** page customers see after paying.

{% hint style="danger" %}
**Use responsibly.** Anything in **Header Code** goes onto your live site exactly as written. Only paste code copied directly from Google. If your site looks broken after saving, go straight back to **Settings**, then **Advanced**, remove what you just added and click **Save Settings** again. Your admin panel is not affected by this field, so you can always get back in to undo a change.
{% endhint %}

{% hint style="success" %}
**Keep it tidy.** If you add several tags over time, leave a blank line between them and put a short label above each one, for example `<!-- Google Analytics -->`. It makes it much easier to find and remove a tag later.
{% endhint %}

#### Using Google Tag Manager instead

Some operators prefer **Google Tag Manager**, a free Google tool for managing lots of tags in one place. If you use it, you install the Tag Manager container instead of the Google tag above, and set up Google Analytics inside Tag Manager.

{% tabs %}
{% tab title="Google tag (simplest)" %}
Paste the Google tag from Step 3 into **Header Code**. That is all you need. This is the right choice for most operators.
{% endtab %}

{% tab title="Google Tag Manager" %}
Google Tag Manager gives you two snippets:

1. The first snippet, which Google says goes "as high in the `<head>` of the page as possible". Paste this into **Header Code**.
2. The second snippet, which starts with `<noscript>` and which Google says goes "immediately after the opening `<body>` tag". Paste this into **Body Code**, just below Header Code in the same **Code Injection** section.

Then set up your Google Analytics tag inside Tag Manager. To record sales, add a trigger for the `purchase` event, as explained in [What Google Analytics Tracks](/helpful-info/what-google-analytics-tracks.md).
{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Install Google Analytics once, not twice.** Use either the Google tag or Google Tag Manager to load the same Google Analytics property, never both. Loading it twice counts every visit and every sale twice.
{% endhint %}

#### What the Body Code box is for

The **Body Code** box sits just below **Header Code** in the **Code Injection** section. Code in this box is added at the very start of the visible part of each page, straight after the opening body tag. It is the place for code a service asks you to put "immediately after the opening body tag", most commonly the `<noscript>` snippet from Google Tag Manager.

A standard Google Analytics tag does not need anything in **Body Code**.

{% hint style="info" %}
The description under **Body Code** in the admin panel mentions the end of the page. The code is actually added at the start of the page body, as described above, which is exactly where Google Tag Manager's `<noscript>` snippet belongs.
{% endhint %}

For more about everything on the Advanced page, see [Advanced Settings](/additional-settings/settings/advanced-settings.md).

***

### Step 5. Check that tracking is working

1. Open your website in a new browser tab and click around a few pages.
2. Go back to **Google Analytics**.
3. Open **Reports**, then **Realtime**. Within a minute or two you should see at least one active user (you).
4. If Google offers a **Test** or **Test installation** button on your data stream, you can use that too. Enter your website address and Google checks whether it can find your tag.

{% hint style="info" %}
**Not seeing yourself in Realtime?** Check these common causes:

* **Ad blockers and privacy browsers.** Many block Google Analytics. Try a different browser, a private window, or your phone on mobile data.
* **The tag was not saved.** Go back to **Settings**, then **Advanced**, and check your tag is still in **Header Code**.
* **Wrong property.** Make sure you are looking at the same Google Analytics property whose Measurement ID is in the tag you pasted.
* **Just installed.** Realtime is usually quick, but give it a few minutes before worrying.
  {% endhint %}

***

### What happens next

* Google Analytics starts collecting visits straight away.
* Most standard reports fill in over the next 24 to 48 hours, so do not worry if they look empty on day one.
* Every time a customer completes an order and reaches the **Order Successful** page, RaffleX sends the sale to Google Analytics automatically. You do not need to set anything up for this.

{% hint style="warning" %}
**Cookies and privacy.** Google Analytics uses cookies and collects data about your visitors. Make sure your privacy policy explains this, and that you have the consent your visitors need to give under UK and EU data protection rules. If you are unsure, take advice before going live.
{% endhint %}

***

### Get more from your tracking

* Learn exactly what RaffleX sends to Google, and how to set up sales reports, in [What Google Analytics Tracks](/helpful-info/what-google-analytics-tracks.md).
* Add [UTM tags](/helpful-info/utm-tags.md) to your marketing links so you can see exactly which email, post or advert each visitor came from.
* Review sales and revenue at any time in your built-in [Analytics](/helpful-info/analytics.md) section, no Google account needed.
* Running TikTok or Google Ads? See [Conversion Event Tracking](/advanced/conversion-event-tracking.md) for ready-made snippets that report basket and purchase events to those platforms.

{% content-ref url="/pages/YAKIhKn9U2lHJy412aDm" %}
[What Google Analytics Tracks](/helpful-info/what-google-analytics-tracks.md)
{% endcontent-ref %}
