Skip to main content
Loop’s tracking feature is a lightweight client-side SDK that integartes with the rest of Loop’s revenue tracking features. … Before installing the tracking script, you need to add your website to Loops on the dashbaord to get your tracking link:

Quick Start

Get Your Website ID

Before installing the tracking script, you need to add your website to Loops on the dashbaord to get your tracking link:
  1. Go to Loops Dashboard - Websites
  2. Click the “Add Website” button
  3. Enter your website name and domain
  4. Copy the provided script tag or note your website-id
Your website ID will be used in the tracking script below.

Installation

Add the copied script tag to your website’s <head> section:
<script
  defer
  src="https://track.loops.fi/script.js"
  data-website-id="your-website-id">
</script>
That’s it! The SDK will auto-initialize and be available globally as window.loops.

Basic Usage

Identify a User

This should be called as soon as a user signs up or logs in to your website. This will associate the user with their events and allow you to track their behavior across their user journey.
// Identify a user
loops.identify('user_123', {
  email: 'john@example.com',
  name: 'John Doe'
});

Place this after a user completes an action on your website. This will track the event and automatically associate it with the user.
// Track custom events
loops.track('purchase', {
  product: 'Premium Plan',
  amount: 99.99,
  currency: 'USD'
});
You can track page views manually with the code below. However, page views are automatically when the SDK intializes and on every route change in SPAs.
// Track page views (auto-tracked by default)
loops.trackPageView();

Features

  • Facebook pixel cookies: Automatically captures _fbc and _fbp for ad attribution
  • Event tracking: Track custom events with any specific data you need
  • Privacy-focused tracking: Built with privacy in mind for compliant analytics
  • Debug mode: Optional debug logging for development

Configuration Options

You can configure the SDK using data attributes:
<script
  defer
  src="https://track.loops.fl/script.js"
  data-website-id="your-website-id"
  data-debug="true"
  data-auto-track="true">
</script>
Available options:
  • data-website-id (required): Your unique website identifier
  • data-debug: Enable debug logging in console (default: false)
  • data-auto-track: Automatically track page views (default: true)

API Reference

loops.identify(userId, data)

Identify a user and associate them with their events. Facebook pixel cookies (_fbc, _fbp) are automatically included.
loops.identify('user_123', {
  email: 'john@example.com',
  name: 'John Doe',
  plan: 'premium'
});
Parameters:
  • userId (string, required): Unique identifier for the user
  • data (object, optional): Additional user properties
    • email (string): User’s email address
    • name (string): User’s full name
    • Any additional custom properties
What gets sent:
{
  user_id: 'user_123',
  email: 'john@example.com',
  name: 'John Doe',
  plan: 'premium',
  fbc: 'fb.1.1234567890.IwAR...',  // Auto-captured
  fbp: 'fb.1.1234567890.123456789'  // Auto-captured
}

loops.track(eventName, eventData)

Track a custom event with optional data.
loops.track('purchase', {
  product: 'Premium Plan',
  amount: 99.99,
  currency: 'USD'
});
Parameters:
  • eventName (string, required): Name of the event
  • eventData (object, optional): Event properties

loops.trackPageView(url, referrer)

Manually track a page view. Note: Page views are auto-tracked by default.
loops.trackPageView(window.location.href, document.referrer);
Parameters:
  • url (string, optional): Page URL (defaults to current URL)
  • referrer (string, optional): Referrer URL

loops.isLoaded()

Check if the tracking script has loaded successfully.
if (loops.isLoaded()) {
  console.log('Analytics ready!');
}
The SDK automatically captures Facebook pixel cookies (_fbc and _fbp) and includes them with every identify() call. This enables accurate attribution for Facebook ad campaigns.

How it works

  1. User clicks a Facebook or Meta ad and lands on your site
  2. Facebook Pixel sets cookies: _fbc (click ID) and _fbp (browser ID)
  3. User browses your site and signs up
  4. You call loops.identify(userId, { email, name })
  5. SDK automatically includes _fbc and _fbp in the event
  6. Your backend and Loops can use these cookies for server-side conversion tracking via Facebook CAPI
  • _fbc: Facebook click ID (e.g., fb.1.1234567890.IwAR...)
  • _fbp: Facebook browser ID (e.g., fb.1.1234567890.123456789)
These cookies are set by the Facebook Pixel and have a 90-day expiration.

What Gets Tracked Automatically

Once installed, the SDK automatically tracks:
  • Page views: Every page visit on your site
  • UTM parameters: Campaign source, medium, and content from URLs
  • Referrers: Where visitors came from
  • Device info: Browser, OS, screen size
  • Facebook cookies: _fbc and _fbp when available

Integrations Overview

Connect Loops with your revenue platforms and ad networks. Loops integrates with your e-commerce platforms, payment processors, and ad networks to provide complete revenue attribution and automated conversion tracking.

Available Integrations

Revenue Platforms

Stripe - Track payments and subscriptions with automatic revenue attribution.
  • Payment sync with customer matching
  • Subscription tracking
  • Automatic conversion events
  • Email-based attribution linking

Ad Networks

Meta Ads (Facebook/Instagram) - Send conversions back to Meta with CAPI (Conversions API) for improved attribution and ad optimization.
  • Server-side conversion tracking
  • Browser-based click ID (fbclid) attribution
  • Enhanced matching with customer data
  • Real-time conversion postbacks

Meta Ads Integration

How It Works

Meta Ads integration uses the Conversions API (CAPI) to send server-side conversions back to Facebook, enabling accurate attribution even with iOS 14+ tracking restrictions.

Revenue Attribution Flow

  1. User Clicks Ad
    User clicks Facebook ad on mobile
    Loops captures: fbclid, utm_source=facebook, utm_medium=cpc
    Visitor session: anon_abc123
    
  2. User Browses Site
    User views products, adds to cart
    All events tracked with fbclid attribution
    Session continues with Facebook attribution
    
  3. User Completes Purchase
    User checks out via Stripe
    Order created in platform
    
  4. Order Synced to Loops
    Loops syncs order via webhook or API
    Matches order email to visitor profile
    Links order to original fbclid from Day 1
    
  5. Conversion Sent to Meta
    Loops sends conversion to Meta CAPI
    Includes fbclid for attribution
    Meta attributes conversion to original ad
    
Result: Purchase attributed to correct Facebook ad, even if checkout happened days later or on different device.

Setup

  1. Connect Meta Ads Account
    • Navigate to Settings → Integrations
    • Click “Connect” for Meta Ads
    • Authorize Loops to access your ad account
    • Select pixel/tag for conversion tracking
  2. Configure Conversion Events
    • Map conversion events (purchase, signup, lead)
    • Configure conversion values
    • Set up enhanced matching (email, phone hashing)
  3. Verify Integration
    • Create a test purchase with a known fbclid
    • Check Event Stream for synced event
    • Verify conversion appears in Meta Events Manager
    • Confirm attribution is correct

Data Sent to Meta

Conversions:
  • Event name (Purchase, Lead, CompleteRegistration)
  • Event time
  • Conversion value and currency
  • Click ID (fbclid) for attribution
Enhanced Matching Data (hashed):
  • Email (SHA-256 hashed)
  • Phone number (SHA-256 hashed)
  • First name, last name
  • City, state, zip code, country

Privacy & Compliance

  • Customer data is SHA-256 hashed before sending to Meta
  • Compliant with Meta CAPI requirements
  • No plaintext PII sent to Meta
  • GDPR-compliant with opt-out support

Stripe Integration

How It Works

Stripe integration syncs payments and subscriptions in real-time, automatically attributing revenue to the correct marketing source.

Customer Journey

  1. Anonymous Visitor
    Day 1: User visits site from Google ad
    visitor_id: anon_abc123
    gclid: Cj0KCQ... (captured from ad)
    
  2. User Signs Up
    User creates account with email
    Email: user@example.com
    Loops links email to visitor_id
    
  3. User Subscribes
    Day 3: User subscribes via Stripe
    Stripe customer created
    Payment processed
    
  4. Attribution Complete
    Loops matches Stripe email to visitor
    Finds original gclid from Day 1
    Attributes revenue to Google ad
    Sends conversion to Google Ads
    

Setup

  1. Connect Stripe Account
    • Navigate to Settings → Integrations
    • Click “Connect” for Stripe
    • Authorize Loops to access your account
    • Grant read permissions for payments and customers
  2. Configure Sync Settings
    • Select events to sync (payments, subscriptions, refunds)
    • Configure attribution matching (email, customer ID)
    • Set sync frequency (real-time webhooks or scheduled)
  3. Verify Integration
    • Create a test payment
    • Check Event Stream for synced payment
    • Verify customer attribution is correct
    • Confirm revenue appears in dashboard

Data Synced from Stripe

Payments:
  • Payment intent ID
  • Amount and currency
  • Customer email and customer ID
  • Payment method and status
  • Created date
Subscriptions:
  • Subscription ID
  • Plan, price, and interval
  • Customer email and customer ID
  • Start date and status
  • Renewal dates
Customers:
  • Email, name, phone
  • Stripe customer ID
  • Total lifetime value
  • Created date

Webhooks

Real-time event processing for instant attribution:
  • payment_intent.succeeded - Payment completed
  • customer.subscription.created - New subscription
  • customer.subscription.updated - Subscription changed
  • invoice.paid - Recurring payment
  • charge.refunded - Refund processed

API Sync

Scheduled syncs run every 15 minutes for:
  • Historical payment data
  • Missing webhook events
  • Customer updates
  • Subscription status changes

Attribution Matching

Email Matching

The most common method for linking Stripe customers to website visitors:
Day 1: User visits site (anonymous)
       visitor_id: anon_abc123
       fbclid: IwAR123 (captured from Facebook ad)

Day 3: User subscribes via Stripe
       Payment email: user@example.com

       Loops matches email to visitor:
       - Searches events for user@example.com
       - Finds visitor_id: anon_abc123
       - Links payment to fbclid: IwAR123

Day 3: Conversion sent to Meta
       fbclid: IwAR123
       event: Purchase
       value: $99.99

Customer ID Matching

For platforms with customer accounts:
  • Stripe customer_id linked to Loops user_id
  • All future payments automatically attributed
  • Subscriptions attributed to original signup source

Integration Benefits

Accurate Revenue Attribution
  • Connect server-side payment data with client-side tracking
  • No lost conversions from iOS 14+ tracking restrictions
  • Cross-device attribution via email matching
  • Server-side conversion tracking bypasses browser limitations
Automatic Conversion Tracking
  • Payments automatically trigger conversion events
  • Subscriptions tracked from signup through renewals
  • Refunds automatically update revenue metrics
  • MRR (Monthly Recurring Revenue) calculated automatically
Customer Journey Completion
  • Link anonymous visitors to paying customers
  • Complete journey from ad click to subscription
  • Cross-device attribution via email
  • Lifetime value tracking per acquisition source

Troubleshooting

Orders/Payments Not Appearing?

Check:
  • Integration is connected and active
  • Webhooks are configured correctly
  • API credentials are valid
  • Event Stream shows synced events

Conversions Not Attributed?

Verify:
  • Customer email matches visitor email
  • Order within attribution window (default 30 days)
  • Click ID present in visitor profile
  • User identified via tracking

Conversions Not Sent to Ad Platform?

Ensure:
  • Ad account connected and authorized
  • Conversion event mapped correctly
  • Click ID present in order attribution
  • Check integration logs for errors