Skip to main content

Customize the website widget with your own code

All plansAdvanced8 minutesUpdated August 26, 2026

Add data-wz-action="contact", "booking", or "whatsapp" to any button or link on your site and it opens the widget, no floating bubble required. You can also call WZ.openLeadForm() and WZ.openBookingForm() from your own code, and override some settings per page with a data-config attribute.

The install snippet gives you a floating bubble in the corner. That is the starting point, not the limit. The same script lets you open the widget from buttons you already designed, drive it from your own JavaScript, and feed conversions into your analytics.

Everything here builds on the snippet from Settings > Integrations > Website Widgets. If you have not installed it yet, start with adding the lead widget to your website.

Open the widget from your own buttons

Add a data-wz-action attribute to any element on the page. Clicking it opens the widget:

html
<a data-wz-action="booking">Book a visit</a>
<button data-wz-action="contact">Get a free quote</button>
<a data-wz-action="whatsapp">Chat on WhatsApp</a>

That is the whole setup. There is nothing to initialize and no ID to match. Your existing "Get a Quote" button in your header keeps its design and starts opening the booking flow.

Three details worth knowing:

  • It works on content that appears later. WorkZen listens at the page level, so buttons added by React, Vue, a slider, or infinite scroll work without re-running anything.
  • It works before the form has ever loaded. The first click loads what it needs.
  • A switched-off feature does nothing. If WhatsApp is disabled in your widget settings, a WhatsApp button stays silent rather than opening a broken screen.

You can use these triggers with or without the floating button. To drop the bubble entirely, install the loader script and simply leave out the <wz-floating-button> tag.

Control the widget from JavaScript

The loader publishes a small API on window.WZ:

CallWhat it does
WZ.openLeadForm()Opens the contact form
WZ.openBookingForm()Opens the booking flow
WZ.ready(fn)Runs your function once the widget has loaded
WZ.submitLead(payload)Sends a lead straight to WorkZen with no form at all

A common use is opening the form after your own logic runs:

html
<button onclick="WZ.openBookingForm()">Schedule my estimate</button>

Prefill the message

WZ.openLeadForm() accepts two options:

javascript
WZ.openLeadForm({
prefillMessage: 'I am interested in the Carriage House door in white.',
extraPayload: { product_sku: 'CH-WHT-16' }
});

prefillMessage is placed in the message field, where the visitor can edit it before sending. Anything you pass in extraPayload travels with the lead. Together they let a product page, pricing table, or configurator tell you exactly what the visitor was looking at.

Change settings on one page only

Your widget settings live in WorkZen and apply everywhere. To vary them on a single page, add a data-config attribute holding JSON. Put it on the loader script tag to affect the whole page, or on the widget tag to affect just that widget. The widget tag wins where both set the same key.

html
<wz-floating-button
config='{"enable_scheduler": false, "contact_us_text": "Ask about bulk pricing"}'>
</wz-floating-button>

These are the keys a page may override:

GroupKeys
Actionsenable_contact_us, contact_us_text, enable_scheduler, scheduler_text, enable_whatsapp, whatsapp_text, whatsapp_number
Booking displaytime_slot_interval, slot_display, range_duration, time_format
Behaviorposition, redirect_url

Anything not on that list stays under WorkZen's control and ignores the page. That includes your theme color, button icon, branding, widget key, working hours, and job types.

Send visitors to a thank-you page

redirect_url sends the visitor somewhere else the moment their submission succeeds, instead of showing the built-in thank-you message. It applies to both the contact form and the booking flow.

html
<wz-floating-button config='{"redirect_url": "https://example.com/thank-you/"}'>
</wz-floating-button>

The redirect only happens after WorkZen confirms the submission, so a failed send leaves the visitor on your page with their answers intact and the error visible. The conversion event still fires first, which means your Google Analytics or Tag Manager tracking records the lead before the visitor moves on. Because this replaces the built-in confirmation, make your destination page say clearly that the message or booking came through. A dedicated thank-you page is also the easiest way to count conversions in analytics and to run Google Ads conversion tracking on a page view.

Track conversions in GA4 or Google Tag Manager

The widget reports four events to your analytics:

EventFires when
workzen_contactform_openThe contact form opens
workzen_contactform_submitA contact lead is submitted successfully
workzen_booking_openThe booking flow opens
workzen_booking_submitA booking is confirmed successfully

The two _submit events fire only after WorkZen confirms the submission, so they are real conversions and safe to use as Google Ads or GA4 conversion triggers.

Both tools are covered automatically:

  • Google Tag Manager: create a Custom Event trigger named workzen_contactform_submit, or use the regular expression workzen_.*_submit to catch every conversion in one trigger. WorkZen pushes to your existing dataLayer and never creates one, so it cannot interfere with your setup.
  • GA4 without Tag Manager: the events arrive on their own. Mark the workzen_*_submit events as conversions in the GA4 admin.

Running both is safe and does not double count.

Frequently Asked Questions

No. The `data-wz-action` triggers and the JavaScript API work on a page that never places a `<wz-floating-button>` tag. Install the loader script, skip the button tag, and drive the widget entirely from your own design.
No. These techniques are part of the widget on every plan. Your theme color, button icon, and removing the "Powered by WorkZen" branding are separate visual settings that require ZenGrow or higher.
Open your browser console. An unrecognized action name logs a warning naming the value it received, which usually means a typo. If there is no warning, the matching feature is switched off in your widget settings, and WorkZen deliberately does nothing rather than opening an empty form.
Yes. Placing it more than once is a no-op. The configuration is fetched exactly once and shared by every widget on the page.
Not from the standard install. Field labels, hidden fields, and required fields are set by WorkZen and are not currently editable from your website's code. Contact support if you need a field change.

This article answers:

  • How do I open the WorkZen widget from my own button?
  • Can I use the widget without the floating button?
  • Is there a JavaScript API for the widget?
  • How do I track widget conversions in Google Analytics?
  • How do I change widget settings on one page only?
  • Can I prefill the widget contact form?

Still have questions?

Browse the help center, or jump in and see it for yourself. WorkZen is free to get started.

Back to Help Center