# Install on Bubble

> Add Reveata to a Bubble app through its header scripts setting, serve it from your own subdomain, and credit payments to their visits.

Bubble adds code to the `<head>` of every page of your app from the app settings. Bubble’s free plan ignores header scripts; use a paid plan.

Copy the snippet from your Reveata dashboard (it contains your website’s tracking id):

```html
<script
  defer
  data-website-id="ws_your_tracking_id"
  data-exclude-paths="/version-test*"
  src="https://reveata.com/js/script.js"
></script>
```

`data-exclude-paths="/version-test*"` keeps visits to your development version out of your numbers when it runs on the same address as your live app.

## Add it to your app

1. In the Bubble editor, open the **Settings** tab, then **SEO / metatags**.
2. Paste the snippet into **Script/meta tags in header**. It is added to every page of the app.
3. Deploy your app to **Live**.

In Reveata, add the website with the address of your live app: your custom domain, or your `.bubbleapps.io` address.

**Go to page** actions load a new page, and changes inside a page (for example a new URL parameter) go through the browser’s History API, which the script follows. Every page view is counted.

## Serve it from your own subdomain

Bubble can’t run proxy code, but with a custom domain the [managed proxy](https://reveata.com/docs/managed-proxy) needs none: add one DNS record (for example `stats.example.com`) where your domain’s DNS is managed, then replace the snippet in **Script/meta tags in header** with the new one Reveata gives you and deploy again.

## Revenue

**The Stripe plugin.** Bubble’s Stripe plugin charges through your own Stripe account, with the keys you entered in the plugin. Connect the same account in Reveata under **Settings → Payments** ([restricted key](https://reveata.com/docs/stripe-restricted-key) or [Connect with Stripe](https://reveata.com/docs/stripe-connect)). Payments made on **Live** then count as revenue; test-mode payments from the development version are not imported.

**Credit payments to visits.** Bubble’s checkout carries no visitor id, so identify signed-in users and Reveata credits their payments by email. Add a workflow on **Page is loaded** (only when **Current User is logged in**), or after **Sign the user up** and **Log the user in**, with the **Run javascript** action from the Toolbox plugin:

```js
window.reveata &&
  window.reveata('identify', {
    userId: 'Current User’s unique id',
    email: 'Current User’s email',
  });
```

Insert **Current User’s unique id** and **Current User’s email** as dynamic data where the text says so. A payment with the same email is then credited to that user’s visits. See [Identify visitors](https://reveata.com/docs/identify-visitors).

**Stripe Payment Links** opened from a link element on your pages are credited with no code: see [Stripe Payment Links and buy buttons](https://reveata.com/docs/stripe-payment-links). Other providers: [Connect a payment provider](https://reveata.com/docs/connect-a-payment-provider).

## Check it works

1. Open your live app in a normal browser window with ad blockers turned off for it.
2. Open **Realtime** in Reveata: your visit appears within a few seconds.
3. If nothing arrives, follow [Verify your installation](https://reveata.com/docs/verify-your-installation).

## Goals

Record goals from a workflow with the **Run javascript** action calling `window.reveata && window.reveata('goal', 'signup')`, or add an HTML element with a link that has `data-reveata-goal="signup"`. See [Custom goals](https://reveata.com/docs/custom-goals).

## Common pitfalls

- **Not deployed to Live.** Header scripts change with the next deployment.
- **The free plan.** Bubble ignores header scripts on it.
- **Visits from `/version-test`.** Keep `data-exclude-paths="/version-test*"` in the snippet so your own testing stays out.
- **Quotes in Run javascript.** If an email or name contains a quote, the code breaks. Use Bubble’s **:formatted as JSON-safe** on the dynamic values, and drop the surrounding quotes.
