Back to Installation

Google Tag Manager Installation Guide

Step-by-step guide to install TwoBucks Analytics via Google Tag Manager.

Quick Start

Method 1: Custom HTML Tag (Recommended)

  1. Go to Tags → New
  2. Configure:
    • Tag Type: Custom HTML
    • Tag Name: TwoBucks Analytics
    • HTML:
<script
  src="https://twobucks.ai/script.js"
  data-website-id="your-website-id"
  async
></script>
  1. Triggering: All Pages
  2. Tag firing priority: Set to fire early (e.g., 1)
  3. Click Save

Track GTM Events

Custom Event Trigger

  1. Go to Triggers → New
  2. Configure:
    • Trigger Type: Custom Event
    • Event name: twobucks_track
  3. Click Save
  4. Create a Custom HTML Tag:
<script>
(function() {
  var eventName = {{Event}};
  var properties = {{Event Properties}} || {};
  
  if (window.twobucks && eventName) {
    window.twobucks(eventName, properties);
  }
})();
</script>

Triggering: Use the custom event trigger above

Data Layer Push

Push events to GTM data layer, then track with TwoBucks:

// Push to GTM
dataLayer.push({
  'event': 'twobucks_track',
  'twobucks_event': 'button_click',
  'twobucks_properties': {
    'button_name': 'Sign Up',
    'page': window.location.pathname
  }
});

GTM Variables

Create variables for easier management:

  1. Go to Variables → New
  2. Configure:
    • Variable Type: Constant
    • Variable Name: TwoBucks Website ID
    • Value: your-website-id
  3. Use in tags: {{TwoBucks Website ID}}

Common Issues

Script Not Loading

  1. Check tag firing priority (set to fire early)
  2. Verify trigger is set to "All Pages"
  3. Check GTM preview mode for errors
  4. Ensure script URL is correct

Timing Issues

If events fire before script loads:

  1. Increase tag firing priority
  2. Use GTM's "DOM Ready" trigger instead of "All Pages"
  3. Add a small delay if needed

Duplicate Scripts

If script loads multiple times:

  1. Check for duplicate tags
  2. Verify trigger conditions
  3. Use tag firing priority to control order

Best Practices

  1. Use Constants: Store website ID in a GTM variable for easy updates
  2. Test in Preview: Always test in GTM preview mode before publishing
  3. Tag Priority: Set analytics tags to fire early (priority 1-10) for accurate tracking

Next Steps