Business features
Track conversion with GTM (Google Tag Manager)
You can track when users trigger tools inside Eloquent (for example, when a conversation is shared via email) by listening to the eloquent:toolcall
event.
This event is dispatched whenever a tool is invoked from your embedded Eloquent agent, and can be connected to analytics or conversion tracking systems such as Google Tag Manager (GTM) and Google Analytics 4 (GA4).
About the eloquent:toolcall
Event
Whenever a tool is executed within an embedded Eloquent agent, the system emits a CustomEvent
called eloquent:toolcall
.
You can listen to it directly in your JavaScript to handle analytics, logging, or trigger other actions.
Example event payload
Here’s what the event’s detail
object looks like:
{
"toolCallId": "call_Zb1CxxWyBfdkSJBcdaRzzKkZ",
"toolName": "share_conversation_via_email",
"args": {
"to": "[email protected]",
"subject": "New lead: track conversion with GTM and GA4",
"bcc": [
"[email protected]"
]
}
}
Listening to the Event
To respond to tool calls, attach an event listener to the global document
or the specific iframe where your Eloquent agent is running:
<script defer>
document.addEventListener("eloquent:toolcall", (event) => {
const { toolCallId, toolName, args } = event.detail;
console.log("Eloquent tool called:", toolName, args);
// Optionally push this data to GTM
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "eloquent_toolcall",
toolCallId,
toolName,
args
});
});
</script>
This pushes the event data to GTM’s dataLayer
, allowing you to trigger tags, send events to GA4, or record conversions.
Setting up Tracking in Google Tag Manager (GTM)
Once the event is pushed into the dataLayer
, follow these steps inside your GTM container.
Create a Custom Event Trigger
- Navigate to Triggers → New
- Choose Trigger Type: Custom Event
- Set Event Name to:
eloquent_toolcall
- (Optional) Add filters, for example:
toolName equals share_conversation_via_email
- Save the trigger as:
Trigger – Eloquent Tool Call
Create a GA4 Event Tag
- Go to Tags → New
- Choose Tag Type: Google Analytics: GA4 Event
- Select your GA4 Configuration Tag
- Set Event Name, for example:
eloquent_toolcall
- Under Event Parameters, you can pass through event details:
toolCallId
→{{toolCallId}}
toolName
→{{toolName}}
args
→{{args}}
- Attach your Trigger – Eloquent Tool Call trigger.
- Save and publish.
3. Mark it as a Conversion in GA4
To track specific tools as conversions (for example, when users share a conversation via email):
- Go to your GA4 Admin → Events
- Find the event name
eloquent_toolcall
- Toggle Mark as conversion
From now on, any time a user triggers a tool (like share_conversation_via_email
), GA4 will record it as a conversion event.
Previous
Analytics & reportingNext
ISO 27001