Skip to main content

Campaign Custom Goals

Written by Charley Bader
Updated this week

You are able to create custom goals to be used within the Campaign Manager for whether a user has visited a specific page, clicked a specific element, matched a certain segment or Custom Javascript.

For example;

  • If you are running an email sign-up experience, you may wish to track interactions with the sign-up CTA or confirmed form submissions

  • If you are running an experience to encourage customers to go back to their basket, you may wish to track visits to the cart page

Setting Up Custom Goals

Custom goals are set-up by navigating to the area within the platform underneath the Campaign navigation item.

From here, select 'Create Custom Goal'. You can then give your goal a name.

Then choose the goal action: Visited Page, Clicked Element, Custom Javascript or Matched Segment.

If your goal is Visited Page, you will then need to add the Page URL criteria of that specific page. For those customers with virtual page views, if you send these as a page view you can set these up as a custom goal using this option.

If your goal is Clicked Element, you can then choose either Element Class, ID, Tree, Text or XPath to identify to element you wish to track. You can find out more about these below.

If your goal is Custom JavaScript, see the Custom JavaScript Goals section below.

If your goal is Matched Segment, select the segment.

Tracking Clicks

When a user clicks an element on the page, there are a number of ways to target that element in custom goals. Note that clicks are registered directly on the element that was clicked and do not bubble up to elements higher in the node tree. In this case, the contains operator is your friend. To target regions or collections of elements, we recommend targeting Element Tree contains element-or-id-class-name.

  • Element Class
    An element class is a name used to label elements in the page’s code, and the same class can be shared by multiple elements. To find it, right-click the element on your site, select Inspect, and look for class="..." in the highlighted code.

    Paste only the class name, for example add-to-cart. The class must uniquely identify the element, otherwise multiple elements may be tracked

  • Element Tree
    The element tree identifies an element by where it sits within the page structure. To find it, right-click the element, choose Inspect, and look at the chain of elements shown above it in the DOM. From this tree, copy one class name or ID only that uniquely identifies the element, for example product-card.

    Paste that single value into the field, for example:
    Element tree - contains - product-card

    The value must appear only once in the element tree, otherwise multiple elements may be tracked. Do not paste multiple values or the full tree path

  • Element ID
    An element ID is a unique name assigned to a single element on the page. To find it, right-click the element, click Inspect, and look for id="..." in the code.

    Paste only the ID value, for example checkout-submit. An ID should appear only once on the page to avoid tracking the wrong element

  • Element Text
    Element text is the visible text shown inside an element. To find it, right-click the element, select Inspect, and locate the text between the opening and closing tags.

    Example:
    <h1 class="title">Product title</h1>

    Paste only the text itself, such as Product title. The text must be unique and consistent, otherwise multiple elements may be tracked.

  • XPath
    XPath it is a flexible way to identify different elements of a web page. To find it, right-click the element, select Inspect, and locate the outermost element you want to target and then right clicking on that element and choosing Copy > Copy XPath

    Example: //*[@id="firstFocusableElement"]/cx-page-layout/cx-page-slot[1]/app-custom-paragraph[1]/div/div/div/div[6]

  • Data Attributes
    Data attributes are attributes given to elements to help us identify them.

    Example: <button data-id="some-element"> has a data-id of "some-element"

    These data attributes are captured when users interact with them, so you can use the data attribute value to target an element in a custom goal

Custom Javascript Goals

Custom JavaScript goals allow you to signal a goal completion from your own tag manager when a condition is met on your side, for example a confirmed email sign-up via a Klaviyo webhook.


Registering a Custom JS Goal Slot
You can register up to 10 custom JS goal slots within the custom goals area. Each slot requires a unique name, for example "Email sign-up confirmed" or "Engagement 30s". This name is used by the tracking script to match incoming signals to the correct slot.

To register a slot, select 'Create Custom Goal', choose Custom JavaScript as the goal action, and enter a name. Once saved, the platform will display a ready-to-use JavaScript snippet pre-populated with that slot name.

Implementing the Snippet
Once a slot is registered, copy the snippet from the platform and add it to your tag manager. The snippet is ready to use without any manual editing, as the slot name is already included.


When the snippet fires, the goal signal is held and attached to the next outgoing event from the MWI tracking script rather than being dispatched immediately. This keeps the signal within the normal interaction stream. If the snippet fires multiple times before the next event, only one signal is recorded and it does not stack.


If no matching slot is registered in the platform when a signal arrives, it is discarded silently.

Managing Slots
You can delete a slot at any time. Deleting a slot does not remove historical data for that slot, but it will no longer accept new signals. The 10-slot limit is enforced in the platform and you will not be able to register an 11th slot.

Once done, then just hit Save!

Seeing Goals in Custom Reporting

Custom goals will automatically be available in all Campaign Reporting underneath Campaign Goal. You just need to choose the correct one from the drop down

Did this answer your question?