Search here to get answers to your questions.

Custom Analytics Scripts (Pro)

In addition to the built-in Google Analytics and Facebook Pixel integrations, ThankRedirect Pro lets you add completely custom JavaScript on your Thank You page — with live order data injected directly into the script. This gives you full flexibility to integrate any analytics platform, CRM webhook, or custom tracking tool.

What It Does

The Custom Analytics Script feature lets you write any JavaScript snippet and have ThankRedirect:

  1. Inject that script into your custom Thank You page after checkout
  2. Replace special shortcode-style placeholders in your script with real order data

This means you don’t need to write any PHP or use a separate plugin to pass order data to third-party tracking tools — it all happens through ThankRedirect’s settings panel.

Available Data Placeholders

Inside your custom script, you can use these placeholders — ThankRedirect will replace them with real order values before the script runs:

Placeholder Replaced With
[transaction_id]Payment transaction ID
[order_total]Order total (numeric)
[currency]Currency code (e.g., USD)
[items]JSON array of items (id, name, quantity, price)
[customer_email]Customer’s email address
[customer_name]Customer’s full name
[payment_method]Payment method title
[shipping_method]Shipping method title

Setting Up a Custom Script

  1. Go to ThankRedirect → Settings → Analytics
  2. Toggle on Enable Custom Script
  3. A code editor area will appear — paste or type your JavaScript here
  4. Use the placeholders above anywhere you need order data
  5. Save your settings

Example Scripts

Send Data to a Zapier Webhook

fetch('https://hooks.zapier.com/hooks/catch/YOUR_HOOK_ID/', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    email: '[customer_email]',
    name: '[customer_name]',
    total: '[order_total]',
    currency: '[currency]',
    transaction_id: '[transaction_id]'
  })
});

TikTok Pixel Purchase Event

ttq.track('PlaceAnOrder', {
  value: '[order_total]',
  currency: '[currency]',
  content_type: 'product',
  contents: [items]
});

Pinterest Tag Checkout Event

pintrk('track', 'checkout', {
  value: '[order_total]',
  currency: '[currency]',
  order_quantity: 1,
  line_items: [items]
});

Console Logging for Testing

console.log('Order completed:', {
  transaction: '[transaction_id]',
  total: '[order_total]',
  customer: '[customer_email]',
  items: [items]
});

Important Notes

  • The script is injected into the <head> of your custom Thank You page — it fires before the page content loads
  • The [items] placeholder is replaced with a raw JSON array — use it directly in JavaScript without extra quoting
  • All string placeholders (email, name, etc.) are output as plain text — wrap them in quotes within your script as needed
  • Your script only runs on the Thank You page after a real order redirect — it does not run during regular page browsing
Pro tip: Use the console logging example first to verify the placeholders are being replaced correctly, then swap it for your real tracking code once you’ve confirmed the data looks right.
Last Updated: March 23, 2026