Existing buttons and links
Ask your agent:
Use my site's existing Delivery details button as a goal. Help me compare its wording without replacing the button or taking it out of the CMS. Show me the draft and check it in an unmeasured preview before anything goes live.
You can measure an existing button or link without rebuilding it. You can also compare its wording in the same element. Use the same approach for a navigation link, header button, or other shared control.
CMS guides: Squarespace, WordPress, Webflow, Shopify, and Drupal.
Choose what to count
- Use a page goal if arrival at a distinct destination, such as a confirmation page, is the outcome you want. If a matching page goal already measures that outcome, use it and leave the control alone.
- Use an interaction goal if activating the control is the outcome, such as opening delivery details. Clicking Submit does not prove that the form succeeded.
- Use a server-confirmed completion goal if only a successful server action should count and no reliable confirmation page records it.
Ask your agent to call get_site and reuse a goal with the right kind, target, and scope. Agree on any change to the goal or CMS with the owner. If you need a new interaction goal, call add_goal with kind: "interaction" and the exact event name as target, such as "show-details". Use scope: "site" only if the owner agrees it should apply to all sets. For one already discovered set, use scope: "experiment:<id>" with the ID from get_site.
Keep the one integration already installed for the visitor's journey. Do not add a second embed or put a private key in the CMS. A goal says what to count. A version set says what visitors can see. A marked control does not need its own version set.
Mark a control
If the CMS or template can add attributes, put data-vc-goal="show-details" on the actual button or link. The event name must match the configured target exactly. A CSS selector locates the element; it is not the goal target. Leave the control's link, form action, focus, and handlers in place.
If you cannot add the attribute at source, add it after the control renders. In this example, #delivery-panel is the stable region and .delivery-details identifies one control inside it. Use hooks you can verify in the rendered page, not generated classes, visible text, or the control's position in a list. Check that the selector matches only the intended control, including in mobile layouts.
(() => {
const panel = document.querySelector('#delivery-panel');
if (!panel) return;
function markGoal() {
for (const control of panel.querySelectorAll('button.delivery-details, a.delivery-details[href]')) {
if (control.hasAttribute('data-vc-goal')) continue;
control.setAttribute('data-vc-goal', 'show-details');
}
}
markGoal();
// If needed, uncomment this line and install the observer once per page:
// new MutationObserver(markGoal).observe(panel, { childList: true, subtree: true });
})();
Run the code in an approved CMS script area. If the control already has a different marker, the code leaves it intact. Check the existing goal before changing the marker. Version Compare handles activation, so do not add another click handler or send a synthetic event.
Controls added or replaced later
Run the marker code from the CMS's after-render hook if it has one. If it does not, uncomment the observer in the example. Install it once, after the stable region exists. Watch the smallest region that stays in place when the CMS replaces the control. The observer checks once per batch of child changes and ignores attribute changes, including its own marker. If the region itself is replaced, use the render hook or choose a stable parent.
If the control is inside a cross-origin iframe, the parent page cannot mark or observe it. If you cannot edit the control's HTML or run approved code where it renders, use a suitable page or completion goal if one is available. If neither measures the right outcome, leave the control unchanged.
Compare wording in place
Keep one button or heading, with the same button behaviour or heading level. If you can edit the template, put data-vc and a stable, unique data-vc-id on that element. Put data-vc-version on each wording's direct child span. Leave the CMS text visible as the fallback and put hidden on the alternative. Keep sets outside one another.
Put versions of initially visible copy, such as a hero headline, in the initial HTML. A footer script that wraps the headline later can expose the original before the alternatives exist. Even with source markup, browser selection can briefly show the fallback.
If the template cannot emit the spans, use this approach for content that renders later, such as a button in a delivery panel. Run it after that content renders. The example moves the original CMS text into the fallback span and keeps the original button in place. To compare a plain heading instead, use its own scoped selector and set ID.
(() => {
const control = document.querySelector('#delivery-panel button.delivery-details');
if (!control || control.closest('[data-vc]') || control.hasAttribute('data-vc-id')) return;
const named = control.closest('button, a[href], h1, h2, h3, h4, h5, h6');
if (named?.matches('[aria-label], [aria-labelledby]')) return;
const text = control.firstChild;
if (control.childNodes.length !== 1 || text.nodeType !== Node.TEXT_NODE ||
!text.data.trim()) return;
const fallback = document.createElement('span');
fallback.setAttribute('data-vc-version', '');
const alternative = document.createElement('span');
alternative.setAttribute('data-vc-version', '');
alternative.textContent = 'Check delivery options';
alternative.hidden = true;
control.append(fallback, alternative);
fallback.append(text);
control.setAttribute('data-vc-id', 'delivery-details-button');
control.setAttribute('data-vc', '');
})();
The browser discovers valid sets added after load. The guard leaves an existing set, rich content, and controls with explicit accessible names alone. Do not strip out icons or formatting, change an aria-label to force a match, or clone a CMS block. Use a template that can keep the visible wording and accessible name in sync for those controls. Give this slot its own set ID and reuse that ID if the CMS replaces the element. Do not use this patch if the CMS keeps rewriting the element's children.
Check the change
Use a recognised CMS preview or proxy development mode. For a new hosted trial, follow hosted test mode before the first save. Put data-vc-test on the existing hosted script on every page of the trial journey. It keeps selection active on ordinary pages without recording views or goals. Automatic CMS previews still apply. Forms, payments, and navigation can still run, so use test destinations and test services.
- Inspect the rendered DOM. Check that the intended button or link alone carries the exact marker. For wording, check for one original element and one visible wording, with both marked spans as direct children. Check that CSS does not override
hidden. - In a CMS preview, use Show versions to try each wording. Check the accessible name, layout, and styling at narrow and wide widths. Tab to the control, then activate a link with Enter or a button with Enter and Space. Check that focus and the original action still work. In the console, check
Version Compare preview: not recordedfor the expected interaction. Try an unmarked neighbouring control and confirm that it does not log the interaction. - Trigger the CMS rerender. Check that a replacement control gets the same marker. Run the wording code again and check that it does not add more spans. If the CMS replaces the element, check that the new one still has one set with the same ID.
- Disable the custom patch and reload. Check that the original CMS wording and action remain. Also check with JavaScript off: server-rendered wording must still have its fallback. A control that the CMS itself creates with JavaScript can still depend on that JavaScript. To roll back, remove your patch or template changes, then reload. Ask before changing any shared goal.
inspect_installation and catalogue_html do not run JavaScript. They can check source evidence, but they cannot confirm a late marker, keyboard behaviour, or goal credit. Report what you saw in the browser separately from measured results. Publish or start measuring only with the owner's approval.