Skip to main content
The browser conversion tag sends a conversion to Gravity from a web page. Use it when you can record the conversion only in the browser, for example on an order confirmation page or with Google Tag Manager (GTM). If your backend confirms the conversion, use server-side conversions (CAPI). A Conversions or CPA campaign needs server-side proof of its conversion event. See Conversion event check. The tag identifies your account with your advertiser ID. The advertiser ID is public and can only record conversions. Do not use your API key in the tag. The API key is for server use only.

Before you start

  • Your advertiser ID. In Events Manager, open Setup, select Or set up manually, and find the Browser conversion tag card. The card shows the tag with your advertiser ID.
  • The Gravity Pixel on your website. The tag reads the attribution context that the Pixel stores, so Gravity can connect the conversion to the ad click.

Add the tag to a page

  1. Copy the tag from the Browser conversion tag card in Events Manager, or copy this tag:
  2. Replace YOUR_ADVERTISER_ID with your advertiser ID.
  3. Set data-type to the event. See Event types.
  4. Set data-value to the conversion value, or remove data-value and data-currency if the conversion has no value.
  5. Put the tag on the page that confirms the conversion, for example the order confirmation page.
The tag sends one conversion each time the page loads.

Event types

Set the event type to the conversion event of your campaign. For a custom conversion event, use the same event name as in your campaign, in lowercase with underscores. For example, use demo_request for a campaign with the custom event Demo request. A signup without a value:
A lead with a value:

Add the tag with Google Tag Manager

  1. In GTM, create a Custom HTML tag.
  2. Paste the tag. To send the value from your data layer, use a GTM variable, for example data-value="{{Conversion Value}}".
  3. Set the trigger to the page view or the event that confirms the conversion, for example a page view on /thank-you or a purchase data layer event.
  4. Publish the container.

Send a conversion from JavaScript

Use JavaScript when the conversion does not load a new page, for example when a form shows a success message.
  1. Load conversion.js once on the page:
  2. When the action is confirmed, call window.gravityConversion:
    The options are advertiserId (required), type, value, currency, orderId, and metadata. They work like the attributes in the table above.

Verify the tag

  1. Open the page with the tag in a browser.
  2. Open the developer tools and select the Network tab.
  3. Find a request to api.trygravity.com/generic/conversions. Make sure that the response contains "status": "ok".

Update an older tag

Older versions of the tag used data-api-key or the apiKey option. These tags still work. To update an older tag:
  1. Replace data-api-key="..." with data-advertiser-id="YOUR_ADVERTISER_ID". In JavaScript, replace apiKey with advertiserId.
  2. Publish the change, including a new version of each GTM container.
  3. Rotate your API key in Settings → Organization, and update your server integrations with the new key.