TrainFair Logo

Publisher Integration Guide

Quickly and easily secure your content.

Overview

TrainFair empowers publishers to monetize their content when it's accessed by bots that scrape the web to power AI search. Our platform detects AI bots, verifies their access rights, and (once we officially launch) ensures you get compensated for your valuable content.

This guide will walk you through integrating TrainFair into your website, allowing you to:

  • Detect when AI companies are accessing your content
  • Block unauthorized AI crawlers
  • Monetize your content through our marketplace
  • Access detailed analytics on AI usage of your content
Quick Integration

If you're in a hurry, the minimum integration requires just adding our script tag and a meta tag with your publisher ID to your website. The full installation takes less than 5 minutes.

Prerequisites

Before you begin integration, make sure you have:

  1. A TrainFair publisher account (create one here if you don't have one)
  2. Access to your website's HTML code or content management system
  3. Your unique Publisher ID (found in your TrainFair dashboard)
Important

TrainFair integration requires your unique Publisher ID. Without it, the system cannot identify your content or attribute earnings to your account.

Integration Steps

Follow these steps to integrate TrainFair into your website:

Step 1: Add the TrainFair Script

Add the following script tag to the <head> section of your website's HTML:

HTML (html)
<script src="https://trainfair-cdn.s3.us-east-2.amazonaws.com/scripts/latest/trainfair.js" async></script>

This script is lightweight, loads asynchronously, and won't impact your website's performance for regular users.

Step 2: Add Your Publisher ID

Add the following meta tag to the <head> section of your website, replacing YOUR_PUBLISHER_ID with your actual Publisher ID:

HTML (html)
<meta name="tf-publisher-id" content="YOUR_PUBLISHER_ID">
Finding Your Publisher ID
Your Publisher ID can be found in your TrainFair dashboard under the "Profile & Settings" tab. It's a unique identifier in UUID format (e.g., 7c5cfc71-7793-402f-a8c3-dce67cabf231).

Step 3: Verify Integration

After adding the script and meta tag, verify that TrainFair is working correctly:

  1. Visit your website in a new browser window or incognito mode.
  2. Open browser developer tools (F12 or right-click → Inspect).
  3. Check the browser console for a message like: [TrainFair]: Configuration loaded.

If you don't see this message, add the debug meta tag to enable verbose logging:

HTML (html)
<meta name="tf-debug" content="true">

You can remove this meta tag once you've confirmed the integration is working.

Step 4: Configure Bot Blocking (Optional)

By default, the TrainFair script monitors AI bots but allows all traffic. To block unregistered AI bots from accessing your content, log into your TrainFair dashboard and enable "Block Unregistered Bots" under the "Profile & Settings" tab.

When enabled, unregistered AI bots will see a message directing them to register with TrainFair instead of accessing your content.

Step 5: Check Your Dashboard

Once integrated, the TrainFair script will immediately begin detecting AI crawlers and recording potential earnings. Visit your TrainFair dashboard to see:
  1. Which AI bots are accessing your content
  2. Which pages are most frequently accessed
  3. How much potential revenue you're generating
  4. Historical trends and patterns

The dashboard updates in real-time as AI crawlers access your content.

Advanced Configuration

Custom Content Selector

By default, TrainFair identifies your main content using common selectors (main, article, etc.). If your site uses different HTML structure, you can specify a custom selector by adding another meta tag:

HTML (html)
<meta name="tf-content-selector" content=".my-content-class, #article-container">

This helps TrainFair accurately hide content from unauthorized bots and properly calculate token counts.

Integration with Content Management Systems

Here's how to integrate TrainFair with popular content management systems:

WordPress

Add the TrainFair script and meta tags to your theme's header.php file, just before the closing </head> tag, or use a plugin like "Header and Footer Scripts".

PHP/HTML (html)

<script src="https://trainfair-cdn.s3.us-east-2.amazonaws.com/scripts/latest/trainfair.js" async></script>
<meta name="tf-publisher-id" content="YOUR_PUBLISHER_ID">

Frequently Asked Questions

Getting Support

If you need assistance with TrainFair integration or have questions, we're here to help: