> For the complete documentation index, see [llms.txt](https://wiki.playgama.com/playgama/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.playgama.com/playgama/guides/deploy-a-game-on-your-own-domain/buy-traffic.md).

# Buy traffic for your site

Run paid campaigns to your Wrap site: enable the Meta Pixel and the Google tag in the developer console, and optimise campaigns for players who actually play, not for clicks.

## Overview

Once the game has a site of its own, paid traffic becomes an option: the visitor lands straight in the game instead of a portal page, and every visit stays yours. To buy that traffic well, the ad network needs two things on the page — **its tag**, and **an event worth optimising for**.

Wrap gives you both without touching any code. In the developer console you enter a Meta Pixel ID and/or a Google tag ID, and the generated site starts reporting two events:

| Event      | When it fires                                                  | In Meta                     | In Google                       |
| ---------- | -------------------------------------------------------------- | --------------------------- | ------------------------------- |
| Page view  | The game page opens                                            | `PageView` (standard event) | `page_view` from the tag itself |
| `game_30s` | The player has spent **30 seconds of active play** in the game | `game_30s` (custom event)   | `game_30s` (event)              |

{% hint style="info" %}
**Why `game_30s` is the goal to optimise for.** A visit costs you money but proves nothing: misclicks, bots and instant bounces all look like visits. Half a minute of actual play is a player. Feed that event to the network and it learns to buy people who play, which is what your revenue is made of.
{% endhint %}

This page covers sites built with [Playgama Wrap](/playgama/guides/deploy-a-game-on-your-own-domain/deploy-with-playgama-wrap.md). If you host the page yourself, see [Do it yourself](#if-you-host-the-page-yourself) at the end.

## Before you start

1. **The site exists in the console.** The game has a Standalone site — see [Deploy with Playgama Wrap](/playgama/guides/deploy-a-game-on-your-own-domain/deploy-with-playgama-wrap.md).
2. **You have the identifiers** of the tags you want to use (see Step 1).
3. **You can publish a new version of the site.** Tags are baked into the build, so they appear on the site only after the next publish.

## Step 1. Get the identifiers

### Meta Pixel ID

In [Meta Events Manager](https://business.facebook.com/events_manager), open your data source (pixel) — the ID is 15 or 16 digits, shown next to its name. You do **not** need to install Meta's base code anywhere: Wrap inserts the pixel for you, you only supply the ID.

### Google tag ID

Three formats are accepted, and they mean different things:

| Prefix         | Where it comes from                                                              | Use it when                                                                           |
| -------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `G-XXXXXXXXXX` | Google Analytics 4 → **Admin → Data streams → your web stream** (Measurement ID) | You want site analytics in GA4 **and** campaign optimisation through GA4 → Google Ads |
| `GT-XXXXXXX`   | A Google tag created in **Google Tag Manager / Google tag** interface            | You already manage the tag centrally                                                  |
| `AW-XXXXXXXXX` | Google Ads → **Tools → Google tag** (conversion ID)                              | You only run Google Ads and want the event as a conversion there                      |

If you are not sure, take the GA4 measurement ID (`G-`): it gives you both audience analytics and a path into Google Ads.

## Step 2. Turn the tags on in the console

Open [developer.playgama.com](https://developer.playgama.com/), go to your game, open the **Standalone site** and press **Edit**. In the content form, switch to the **Marketing & Ads** tab — the **Tracking** section is at the top.

* Tick **Enable Meta Pixel** and paste the ID into **Meta Pixel ID** — 15 or 16 digits, nothing else.
* Tick **Enable Google Tag** and paste the ID into **Google Tag ID** — `G-`, `GT-` or `AW-` followed by at least six characters.

Both identifiers are checked against those formats in the form and again on the server when the version is created, so a typo stops the publish instead of quietly producing a site without a tag. An identifier is only used while its checkbox is on: untick it, publish, and the tag disappears from the site.

{% hint style="warning" %}
The tags load together with the page, like the rest of the site's scripts — Wrap does not yet gate them behind a consent prompt. If you buy traffic in regions where third-party tags need consent first, take that into account before enabling them.
{% endhint %}

## Step 3. Publish and verify

Press **Validate and publish**. The tag code is part of the build, so it goes live with the new version — the currently published site keeps running until then.

The same build is served on the technical hostname `<game>.wrap.playgama.com`, so you can check the tags there before the domain is connected.

To verify, open the site and play for at least 30 seconds without switching tabs:

* **Meta** — Events Manager → **Test events** (or the Meta Pixel Helper extension): `PageView` on load, `game_30s` after 30 seconds of play.
* **Google** — Tag Assistant, or GA4 → **Realtime / DebugView**: `page_view` on load, `game_30s` after 30 seconds of play.

{% hint style="info" %}
Ad blockers block both tags, as they do on any other site — the player still plays, the site still earns, and Playgama's own analytics in your developer cabinet is unaffected. Expect the network's numbers to be lower than the cabinet's.
{% endhint %}

## What exactly is sent

* **Only the game page carries the tags.** The service pages of the site — privacy, terms, contact, account — load no tag, so a page view means "someone opened the game page".
* **`game_30s` counts active play, not time on the page.** The clock runs only while the tab is visible and the game is actually running: time spent on the preview before the player presses play, or on a hidden tab, does not count. The event fires once per page load.
* **Nothing else is forwarded.** The site's internal milestones (`game`, `game_60s`), ad events, purchases and sign-ins stay in Playgama analytics and never reach your tags.
* **No player data is attached.** The events carry no custom parameters, no identifiers and no purchase amounts.

## Use `game_30s` as the campaign goal

The event only becomes useful once the campaign is optimised for it.

### Meta

1. Wait for the first `game_30s` events to arrive — a custom event appears in the interface only after it has been received.
2. Create a campaign with a conversion objective, and at the ad set level choose your pixel as the data source and **`game_30s`** as the conversion event. If the custom event is not offered in the list, create a **Custom Conversion** from it in Events Manager and select that instead.
3. Give it volume. Optimisation stabilises at roughly a few dozen conversions per ad set per week; below that the network has too little signal, and it is usually better to start on a cheaper goal (traffic, landing page views) and switch to `game_30s` once the event flows steadily.

### Google Ads through GA4 (`G-` tag)

1. In GA4, open **Admin → Events**, find `game_30s` and mark it as a **key event**.
2. Link the GA4 property to your Google Ads account.
3. In Google Ads, import the key event as a conversion action (**Goals → Conversions → Import → Google Analytics 4**) and set it as the campaign goal.

### Google Ads directly (`AW-` tag)

With an `AW-` tag the events reach Google Ads itself. In **Goals → Conversions** create a new conversion action for your website and pick `game_30s` among the events the tag has already collected on your domain. If the event is not listed yet, play the site for 30 seconds a couple of times and repeat — an event that has never been received cannot be selected.

## Reading the numbers

Three sources will disagree, and that is normal:

* **The ad network** counts conversions its tag saw, within its own attribution window.
* **GA4** counts events in its own sessions and windows.
* **The Playgama developer cabinet** counts plays and revenue for the site itself.

Ad blockers, ITP and different attribution rules make the gap. Use the network's numbers to steer the campaign, and the cabinet to judge whether the traffic actually pays: revenue from the site lives there, and no tag ever sees it.

## If you host the page yourself

On a page you build yourself ([Deploy by yourself](/playgama/guides/deploy-a-game-on-your-own-domain/deploy-by-yourself.md)) the tags are yours to install — paste the standard Meta and Google snippets into the page head as usual. Wrap's `game_30s` has no equivalent there, but the same signal is a few lines of code: count visible time and report once at 30 seconds.

```html
<script>
  // Report 30 seconds of visible play to whichever tags are on the page.
  var playedMs = 0, lastTick = Date.now(), reported = false;
  setInterval(function () {
    var now = Date.now();
    if (!document.hidden) playedMs += now - lastTick;
    lastTick = now;
    if (playedMs >= 30000 && !reported) {
      reported = true;
      if (typeof fbq === 'function') fbq('trackCustom', 'game_30s');
      if (typeof gtag === 'function') gtag('event', 'game_30s');
    }
  }, 1000);
</script>
```

Start the timer when the game becomes visible rather than on page load if your page shows a menu or a preview first — the point of the event is that it marks a player, not a visitor.

## Troubleshooting

* **"Meta Pixel ID is 15 or 16 digits"** — the field takes the numeric ID only, not the pixel's name and not the business account ID.
* **"Google Tag ID looks like G-XXXXXXXXXX, GT-XXXXXXX or AW-XXXXXXXXX"** — check the prefix: a GA4 *stream* ID or a measurement protocol secret will not do.
* **The tag is not on the live site** — the version containing it has not been published. Publish again, then reload the page bypassing the cache.
* **`PageView` arrives but `game_30s` never does** — the event needs 30 seconds of real, visible play. Test it yourself with the tab in the foreground before assuming it is broken.
* **The event fires on the game page but not elsewhere** — by design; the service pages carry no tags.
