Track conversions with JavaScript and give goals a value
You'll count conversions your site's code knows about, like a completed checkout, and see the value each campaign or test version brings in.
Count the conversions only your site's code knows about, like a completed checkout, a booked call or a signup inside your app, and see how much value each campaign and test version brings in. One line of JavaScript reports the conversion. RightMessage handles which campaign and version gets the credit.
Use a JavaScript event goal when a page view, click or form submission can't tell you the conversion really happened. You'll need someone who can add code to your site.
1. Create a JavaScript event goal
- Open Conversion Goals under Personalize and choose New goal.
- Under What should count as a conversion?, choose JavaScript event ("Your site's code reports a conversion, like a completed checkout.").
- Enter an Event key, such as
purchase. It starts with a lowercase letter and uses only lowercase letters, digits and underscores, up to 40 characters. - Under Which pages?, leave the default to count it on every page, or narrow it to the pages where the code runs.
- Optionally, enter a Value per conversion, such as your average order value.
- Name the goal, add it to the campaigns that should measure it, and choose Create goal.
JavaScript events can't be checked against past visits. Conversions start counting once you create the goal and add the code to your site.
2. Report the conversion from your site
Add this where your code knows the conversion happened, using your goal's event key:
To record what this conversion was worth, and to make it safe to repeat, pass a value and an id:
valueoverrides the goal's Value per conversion for this conversion. It's a number from 0 to 1,000,000,000, rounded to 2 decimals, with no currency.idis your own reference, such as an order number: up to 64 letters, digits,_,.,:or-. If a visitor reloads the thank-you page, the sameiddoesn't count the conversion twice. Without anid, each goal counts once per page view.
The call is safe to make before RightMessage loads: it waits and is recorded once RightMessage runs. It never throws. An unknown key is ignored, and the browser console shows [RightMessage] Ignored conversion: unknown or invalid key "<key>". An invalid value or id logs a warning, and the conversion still records.
Nothing is recorded for an excluded browser, before cookie consent when the project waits for consent, or in a dashboard preview. The debugger shows the conversion it would have sent. See the JavaScript command reference for every detail.
3. Read the value in your results
Wherever the goal's results appear, a line beside them shows Conversion value (the total) and Value per visitor, such as "Conversion value 1,240.50 · Value per visitor 3.10".
Value is "Shown next to results. It never decides a winner." A/B test verdicts always come from how many visitors converted. Use value to judge whether a winner is worth keeping, for example when a version gets fewer but larger orders.
Check that it's working
- Open the page where the code runs in a browser that isn't excluded, and complete a test conversion.
- Check the goal's overview for the new conversion.
- If it doesn't appear, check the browser console for an
Ignored conversionmessage, the goal's pages, and that the event key matches exactly. Keys are case-sensitive.
For other goal types, see create and manage conversion goals.