Track Link Clicks
How to track when someone clicks on a specific link.
Use the following instructions to track when someone clicks on a link:
Link Click Tracking with Google Analytics
This document explains how to track link clicks and file downloads from your AI assistant chatbot.
Events Tracked
The chatbot widget now automatically tracks the following events:
Event Type | Description | Tracking Data |
| When a user clicks a link in an assistant response |
|
| When a user downloads a file from an assistant |
|
Implementation
1. Add Google Analytics to Your Site
First, make sure you have Google Analytics set up on your site. You can use any of these methods:
Google Tag Manager (Recommended)
Google Analytics 4 (GA4)
Universal Analytics (UA)
2. Add the Analytics Tracker Script
Add the analytics tracker script after your chatbot embed script:
Copy<!-- Chatbot widget --> <script src="https://app.strictly.ai/widget/chat-embed.js" data-bot-id="YOUR_CHATBOT_ID"> </script> <!-- Analytics tracking for chatbot --> <script src="https://app.strictly.ai/scripts/analytics-tracker.js" data-chatbot-id="YOUR_CHATBOT_ID" data-tracking-type="gtm" data-debug="false"> </script>
3. Configure Parameters
Parameter | Description | Options |
| Your chatbot ID (must match the embed script) | Required |
| How to track events |
|
| Enable console logging |
|
4. Set Up Google Tag Manager (GTM)
If using GTM (recommended), follow these steps:
In GTM, create a Custom Event trigger that listens for
link_clickandfile_downloadCreate tags that fire on these triggers to send data to your analytics platform
Use the data variables (
url,link_text, etc.) to enrich your analytics
Example GTM configuration:
Create a Custom Event trigger:
Event name:
link_clickThis trigger fires on: All Custom Events
Create another Custom Event trigger for
file_downloadCreate a GA4 event tag:
Tag type: Google Analytics: GA4 Event
Event name:
{Event}Event parameters:
url:
{url}link_text:
{link_text}link_type:
{link_type}chatbot_id:
{chatbot_id}
5. Testing
To test if event tracking is working properly:
Open your website with the chatbot
Open your browser's Developer Tools
Enable GTM/GA debug mode
Set
data-debug="true"in the analytics tracker scriptClick links in assistant responses and check the console and GA debug output
Additional Notes
Link clicks are tracked before navigation occurs to ensure the event is properly recorded
File downloads are detected automatically based on common file extensions
All events include the chatbot ID for proper attribution and analysis
Events are tracked even in iframes due to the parent-child window communication