Custom Goal

Overview

A Custom Goal can be triggered anywhere you want, but requires explicit integration - unlike Pageview, On Click, or Scroll, which need no code.

Creating a Custom Goal

  1. From the left menu, click Advanced, then Goals.

  2. Press New Goal.

  3. Choose a name, description, and whether to allow multiple conversions per visitor session (see below).

  4. Select Custom Goal as the goal type.

  5. Press Save and wait for the code snippet to be generated.

Selecting Custom Goal as the goal typeThe generated code snippet after saving

Integrating the goal

The generated snippet looks like this:

<script>_mktz.push(['_Goal','NAME','VALUE']);</script>
  • NAME - the goal's name as defined in Explore.

  • VALUE - a numeric value for the conversion, in 12345.67 format without a currency symbol. Use 0 if the conversion has no value.

Insert this snippet into any JavaScript event on your website - onclick, onload, onmouseover, onmouseout, onfocus, and so on.

Note

The main tracking code must be installed on every page where this snippet is used. VALUE also accepts negative numbers.

Installing a Custom Goal via GTM

If your website already uses Google Tag Manager, you can deploy a Custom Goal through it instead of editing your site's code directly.

Warning

Before starting, confirm: the Explore tracking code is installed, GTM is installed, and you're comfortable with basic JavaScript for defining GTM trigger conditions.

  1. In Google Tag Manager, open your workspace and go to Tags.

  2. Press New.

  3. Name the tag to reflect its type, platform, and purpose - e.g. HTML - Explore - Goal - Add to Cart.

  4. Under Tag Configuration, select Custom HTML.
    GTM Tag Configuration with Custom HTML selectedThe snippet pasted into the Custom HTML tag

  5. Paste the snippet, replacing the goal name to match your action, e.g.
    <script>_mktz.push(['_Goal','add-to-cart','VALUE']);</script>

  6. Create a trigger defining when the tag should fire (e.g. "add to cart click").

  7. Name the trigger (e.g. Click - Add to Cart) and set the trigger type to All Elements → Click.

  8. Under Some Clicks, add a condition - for example, Click text equals "Add to cart" (assuming that's your button's exact text).
    GTM trigger condition: Click text equals Add to cart

    Note

    If parameters like Click Text, Click Classes, or Click ID aren't showing up, enable them first from the parameter dropdown.

  9. Save the tag.

  10. Use GTM's Preview mode to confirm the tag fires as expected - you'll be prompted for your website's URL and to trigger the action manually.

  11. Publish your container, then wait a couple of hours before checking that the Goal Count in Explore is increasing.

Single vs. Multiple Conversions

When creating the goal, you can enable allow multiple conversions per visitor session.

  • Disabled (default) - only the first matching event in a session counts as a conversion.

  • Enabled - every matching event in the same session counts as a separate conversion.

Updated