Skip to main content

Overview

Google Tag Manager (GTM) provides a flexible way to deploy Trodo without modifying your website’s source code. This guide covers setup, configuration, and best practices.

Quick Setup

1

Open Google Tag Manager

Go to tagmanager.google.com and select your container
2

Create New Tag

Click TagsNewTag ConfigurationCustom HTML
3

Add Trodo Script

Paste the following code:
<script>
  var script = document.createElement('script');
  script.src = 'https://cdn.trodo.ai/scripts/analytics/trodo.script.min.js';  
  script.setAttribute('site-id', 'YOUR_SITE_ID');
  script.setAttribute('auto-events', 'true');
  document.head.appendChild(script);
</script>
Replace YOUR_SITE_ID with your actual Site ID from Trodo dashboard.
4

Set Trigger

Click TriggeringAll Pages (or your preferred trigger)
5

Save and Publish

Click Save, then Submit to publish your changes

Configuration Options

Basic Configuration

<script>
  var script = document.createElement('script');
  script.src = 'https://cdn.trodo.ai/scripts/analytics/trodo.script.min.js';  
  script.setAttribute('site-id', 'YOUR_SITE_ID');
  script.setAttribute('auto-events', 'true');
  document.head.appendChild(script);
</script>

Full Configuration

<script>
  var script = document.createElement('script');
  script.src = 'https://cdn.trodo.ai/scripts/analytics/trodo.script.min.js';  
  script.setAttribute('site-id', 'YOUR_SITE_ID');
  script.setAttribute('auto-events', 'true');
  script.setAttribute('auto-events-disabled-paths', '/admin,/internal,/checkout');
  script.setAttribute('auto-events-disabled-events', 'text_selection,copy_action');
  document.head.appendChild(script);
</script>

Configuration Attributes

AttributeTypeDefaultDescription
site-idstringrequiredYour Trodo site identifier
auto-eventsbooleantrueEnable automatic event tracking
auto-events-disabled-pathsstring''Comma-separated URL paths to exclude
auto-events-disabled-eventsstring''Comma-separated auto-events to disable

Using GTM Variables

You can use GTM variables in your configuration:

Site ID from Variable

  1. Create a Constant variable for your Site ID
  2. Reference it in the tag:
<script>
  var script = document.createElement('script');
  script.src = 'https://cdn.trodo.ai/scripts/analytics/trodo.script.min.js';  
  script.setAttribute('site-id', '{{Trodo Site ID}}');
  script.setAttribute('auto-events', 'true');
  document.head.appendChild(script);
</script>

Environment-Based Configuration

Use GTM’s environment feature for staging vs production:
<script>
  var siteId = '{{Trodo Site ID}}'; // Different per environment
  var script = document.createElement('script');
  script.src = 'https://cdn.trodo.ai/scripts/analytics/trodo.script.min.js';  
  script.setAttribute('site-id', siteId);
  script.setAttribute('auto-events', 'true');
  document.head.appendChild(script);
</script>

Custom Event Tracking

Via Data Layer

Push events to GTM’s data layer, then forward to Trodo: On your website:
dataLayer.push({
  event: 'trodo_event',
  eventName: 'button_clicked',
  eventProperties: {
    button_name: 'signup',
    button_location: 'header'
  }
});
GTM Tag (Custom HTML):
<script>
  if (window.Trodo) {
    var eventName = '{{DL - eventName}}';
    var eventProps = '{{DL - eventProperties}}';
    window.Trodo.track(eventName, eventProps);
  }
</script>
Trigger: Custom Event = trodo_event

Direct Tracking

After Trodo loads, you can track directly:
<script>
  // Wait for Trodo to be available
  function trackWithTrodo(eventName, properties) {
    if (window.Trodo) {
      window.Trodo.track(eventName, properties);
    } else {
      setTimeout(function() {
        trackWithTrodo(eventName, properties);
      }, 100);
    }
  }
  
  trackWithTrodo('gtm_custom_event', {
    source: 'gtm',
    trigger: '{{Trigger Name}}'
  });
</script>

User Identification

Identify Users via GTM

Create a tag to identify users when they log in:
<script>
  if (window.Trodo && '{{User ID}}') {
    window.Trodo.identify('{{User ID}}');
    window.Trodo.people.set({
      email: '{{User Email}}',
      name: '{{User Name}}',
      plan: '{{User Plan}}'
    });
  }
</script>
Trigger: Custom Event = user_logged_in

Custom product events

Fire Trodo.track() from a tag when a data layer event occurs (for example activation or agent completion):
<script>
  if (window.Trodo) {
    window.Trodo.track('{{Event Name}}', {
      workflow_id: '{{Workflow ID}}',
      outcome: '{{Outcome}}'
    });
  }
</script>
Trigger: Your custom event (e.g. agent_run_completed)

Trigger Configurations

Load Trodo on every page:
  1. Trigger Type: Page View
  2. Trigger fires on: All Page Views

Specific Pages Only

Load only on certain pages:
  1. Trigger Type: Page View
  2. Trigger fires on: Some Page Views
  3. Condition: Page Path contains /app

Exclude Pages

Exclude admin or internal pages:
  1. Create trigger: Page View - Some Page Views
  2. Condition: Page Path does not contain /admin
  3. AND Page Path does not contain /internal
Load only after consent:
  1. Trigger Type: Custom Event
  2. Event name: consent_granted
// After user grants consent
dataLayer.push({ event: 'consent_granted' });

Tag Sequencing

Load Order

Ensure Trodo loads before dependent tags:
  1. Open your Trodo tag
  2. Go to Advanced SettingsTag Sequencing
  3. Check “Fire a tag before [Trodo] fires” if needed
  4. Check “Fire a tag after [Trodo] fires” for dependent tags

Wait for Trodo

For tags that depend on Trodo:
<script>
  function waitForTrodo(callback) {
    if (window.Trodo) {
      callback();
    } else {
      setTimeout(function() {
        waitForTrodo(callback);
      }, 50);
    }
  }
  
  waitForTrodo(function() {
    // Your code that needs Trodo
    window.Trodo.track('dependent_event');
  });
</script>

Debugging

GTM Preview Mode

  1. Click Preview in GTM
  2. Navigate to your website
  3. GTM debug panel shows:
    • Tag firing status
    • Variable values
    • Data layer events

Verify Trodo Loading

In browser console:
// Check if Trodo loaded
console.log(window.Trodo); // Should show Trodo object

// Check initialization
console.log(window.Trodo.getSiteId()); // Should show your Site ID

Network Tab

Check for requests to:
  • cdn.trodo.ai (script load)
  • api.trodo.ai (event tracking)

Common Issues

  1. Check trigger conditions in GTM Preview
  2. Verify container is published
  3. Check for JavaScript errors in console
  1. Verify Site ID is correct
  2. Check domain is whitelisted in Trodo
  3. Look for blocked requests (ad blockers)
  4. Verify in Network tab that API calls succeed
  1. Ensure Trodo is only loaded once
  2. Check for duplicate tags in GTM
  3. Don’t load via both GTM and direct script
Add to your Content Security Policy:
script-src 'self' https://cdn.trodo.ai;
connect-src 'self' https://api.trodo.ai;

Best Practices

Use Folders

Organize your Trodo tags:
Tags/
├── Trodo/
│   ├── Trodo - Base Script
│   ├── Trodo - Identify User
│   ├── Trodo - Track Signup
│   └── Trodo - Track Purchase

Naming Convention

Use clear, consistent names:
✅ Good:
"Trodo - Base Script (All Pages)"
"Trodo - Track Button Click"
"Trodo - Identify Logged In User"

❌ Poor:
"Tag 1"
"New Tag"
"Custom HTML"

Version Control

Use GTM’s built-in versioning:
  1. Add descriptions to each version
  2. Name versions meaningfully: “Added Trodo tracking”
  3. Use workspaces for team collaboration

Testing

Always test before publishing:
  1. Use GTM Preview mode
  2. Test on staging environment first
  3. Verify events appear in Trodo
  4. Check for console errors

Next Steps

Auto-Events

Configure automatic tracking

SDK Reference

Track custom events