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

link_click

When a user clicks a link in an assistant response

url, link_text, link_type

file_download

When a user downloads a file from an assistant

url, link_text, link_type

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:

<!-- 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

List of parameters below:

Parameters

Description

Options

data-chatbot-id

Your chatbot ID (must match the embed script)

Required

data-tracking-type

How to track events

gtm (Default), ga4, or ua

data-debug

Enable console logging

true or false

Set Up Google Tag Manager (GTM) If using GTM (recommended), follow these steps:

  1. In GTM, create a Custom Event trigger that listens for link_click and file_download

  2. Create tags that fire on these triggers to send data to your analytics platform

  3. Use the data variables (url, link_text, etc.) to enrich your analytics

Example GTM configuration:

  1. Create a Custom Event trigger:

  • Event name: link_click

  • This trigger fires on: All Custom Events

  1. Create another Custom Event trigger for file_download

  2. Create 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}

  1. Testing To test if event tracking is working properly:

    1. Open your website with the chatbot

    2. Open your browser's Developer Tools

    3. Enable GTM/GA debug mode

    4. Set data-debug="true" in the analytics tracker script

    5. Click 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