Skip to main content

Event examples

Copy‑paste recipes for common business events. Fire them from your own click and form‑submit handlers. All examples assume the SDK is installed.

Contact Us Submitted

Fire after a successful contact‑form submission (not on click):

JourneyLayer.track('Contact Us Submitted', {
name: form.name.value,
email: form.email.value,
phone: form.phone.value,
source_page: location.href,
});
// Optionally identify the lead by their email:
JourneyLayer.identify({ identity: form.email.value, email: form.email.value });

Lead Form Submitted

For other enquiry/lead forms, track them separately with a form_name:

JourneyLayer.track('Lead Form Submitted', {
form_name: 'homepage_hero',
name, email, phone,
interested_in: 'WhatsApp API',
page_path: location.pathname,
});

Phone Number Clicked

Capture clicks on tel: links:

<a
href="tel:+919999999999"
onclick="JourneyLayer.track('Phone Number Clicked', { phone: '+919999999999', link_text: this.textContent, page_url: location.href })"
>
Call us
</a>

WhatsApp Clicked

Capture clicks on WhatsApp links/buttons:

<a
href="https://wa.me/919999999999"
onclick="JourneyLayer.track('WhatsApp Clicked', { whatsapp_number: '919999999999', placement: 'floating', page_url: location.href })"
>
Chat on WhatsApp
</a>

Service Page Viewed

Fire on pages that represent a specific service/product:

JourneyLayer.track('Service Page Viewed', {
service_name: 'Full Body Health Checkup',
page_url: location.href,
page_title: document.title,
});

Delegated tracking (no inline handlers)

Prefer to keep markup clean? Use one delegated listener for all phone & WhatsApp links:

document.addEventListener(
'click',
function (e) {
var a = e.target.closest && e.target.closest('a[href]');
if (!a) return;
var href = a.getAttribute('href') || '';
if (/^tel:/i.test(href)) {
JourneyLayer.track('Phone Number Clicked', {
phone: href.replace(/^tel:/i, '').replace(/[^\d+]/g, ''),
link_text: a.textContent.trim(),
page_url: location.href,
});
} else if (/wa\.me|whatsapp\.com/i.test(href)) {
JourneyLayer.track('WhatsApp Clicked', {
link_text: a.textContent.trim(),
page_url: location.href,
});
}
},
true,
);
Keep names consistent

Use the same event name everywhere (Phone Number Clicked, not phone_click in one place and Phone Clicked in another). Consistent names make segments and funnels far easier to build.

Privacy

Avoid sending sensitive free‑text (e.g. the body of a contact message) unless you actually need it. Prefer a flag like has_message: true or a length, and never put personal data in the page URL.