The client needed successful chats reported in GA4 through Google Tag Manager. The chat runs in a cross-origin iframe from text2chat-widget.servicetitan.com, so the page can’t read anything inside it. ServiceTitan’s tracking guide covers its WebChat widget, but the site used Chat to Text, a different product with no documented events. Early scripts were built for the wrong widget, and a guessed “success” tag would have failed silently. Reading the widget’s JavaScript then showed it sends the page only ready and setFrameSizes messages, with nothing on submit.
The widget resizes its iframe when it opens and closes, and announces each resize to the page. A GTM Custom HTML tag turns those messages into one dataLayer event:
{event: 'servicetitan_chat', status: 'open'}{event: 'servicetitan_chat', status: 'closed'}The tag checks the message origin and fires only on a real state change. GTM needs one Custom Event trigger and a Data Layer Variable status, passed to the GA4 Event tag. A trigger condition of status equals open counts opens only.
status parameter, which needs one trigger instead of two.