AxiTrace Start Trial event - parameters, required fields, and integration examples.

Start Trial Event

Track when users begin a free trial of your product or service. This event maps to Facebook StartTrial standard event, enabling trial-to-paid conversion analysis and value-based ad optimization for SaaS and subscription businesses.

POST /v1/start_trial

When to Use This Event

The start_trial event should be triggered when a user begins a free trial period. This typically occurs when:

  • User signs up for a free trial of your SaaS product
  • User activates a trial subscription
  • User starts a freemium-to-premium trial
  • User begins a limited-time product demo
  • User activates a trial license or access period
SaaS Conversion Funnel

Start Trial is a key mid-funnel conversion event for subscription businesses:

page.view → subscribe (lead) → start_trial → transaction.charge (conversion)

Client-Side vs Server-Side Tracking

Server-Side Tracking Recommended

Start Trial events should be tracked from your server-side code, not from the frontend.

Server-side tracking is essential because:

  • Accurate data - track only after trial is actually provisioned
  • Security - use Secret Keys without exposing them to browsers
  • Reliability - not affected by ad blockers or browser issues
  • Integration with your subscription/billing system
  • Fraud prevention - validate trial eligibility server-side

However, the JavaScript SDK does support start_trial via track(). If you use it, the SDK will fire the Facebook StartTrial pixel and forward the event to the backend. Do not use both - choose one approach to avoid double-counting.

Facebook & TikTok Pixel Mapping

AxiTrace Event Facebook Pixel TikTok Pixel
start_trial StartTrial Not supported
TikTok Does Not Support StartTrial

TikTok's Events API does not have a StartTrial standard event. When you track start_trial, only the Facebook pixel will fire - the TikTok pixel is skipped. If you need to track trials for TikTok campaigns, consider using TikTok's custom events or mapping to an alternative TikTok standard event.

Event Name Aliases

The JavaScript SDK accepts these name formats that all map to the same event: start_trial, startTrial, and trial.start. All are routed to the same handler internally and map to Facebook StartTrial.

Request Parameters

User Identification

At least one of these identifiers is required:

Field Type Description
client_id string Your custom user/visitor identifier (use SDK's vt_vid cookie value)
user_id string Authenticated user ID
session_id string Current session identifier (use SDK's vt_sid cookie value)
Server-Side: Match SDK User Identifiers

For server-side events, pass the same user identifiers that the JavaScript SDK generates. The SDK stores these in cookies:

  • vt_vid - Visitor ID (persistent anonymous identifier → use as client_id)
  • vt_sid - Session ID (current browsing session → use as session_id)
  • vt_uid - User ID (set via identify() → use as user_id)

Read these cookies and pass them in your server-side events to properly link all events to the same user profile. See the User Identification guide for complete details.

Trial Details

Field Type Required Description
plan_name string Recommended Name of the plan being trialed (e.g., Pro, Enterprise, Premium)
trial_period_days integer Recommended Trial duration in days (e.g., 7, 14, 30). Must be >= 0.
trial_value number Recommended Monetary value of the trial (for Facebook CAPI attribution). Must be >= 0.
trial_currency string Recommended ISO 4217 currency code (e.g., USD, EUR). Product prices must use the same currency.
eventSalt string Optional Your stable ID for this trial start. A retried request with the same eventSalt is stored once.
products array Optional Products the trial is about (for example the plan), in the transaction line shape. An invalid line is dropped and the trial start is still stored. See Rules for lead products.

Additional Trial Parameters (via params)

Include these fields in the params object for enhanced tracking:

Field Type Description
predicted_ltv number Predicted lifetime value of the customer (for Facebook CAPI optimization)
trial_type string Type of trial: free, paid, freemium, demo
billing_cycle string Billing cycle after trial: monthly, annual, lifetime
features array List of features included in trial

Customer Data (for Facebook CAPI)

Include these fields in the params object to enhance Facebook Conversions API matching:

Field Type Description
phone string Phone number (E.164 format recommended, e.g., +14155551234)
first_name string User's first name
last_name string User's last name
city string City name
state string State or province (2-letter code for US, e.g., CA)
zip string ZIP or postal code
country string Country code (ISO 3166-1 alpha-2, e.g., US, GB)
gender string Gender: m or f
fbp string Facebook Pixel browser ID (from _fbp cookie)
fbc string Facebook Click ID (from _fbc cookie or URL)

Products (Leads)

A trial start can carry the products it is about as a root products array, plus an eventSalt so a retry is stored once. The value stays trial_value with trial_currency, and that currency is the currency of the product prices. Products are optional, appear on the lead in Leads and are never counted as revenue. An invalid product line is dropped; the trial start is always stored. Calls without these fields work exactly as before.

<?php
// PHP SDK 1.12.0 or later
$event = (new StartTrialEvent('Pro Plan'))
    ->setTrialValue(49.99, 'USD')
    ->setEventSalt('trial-' . $accountId)
    ->addProduct(['sku' => 'PLAN-PRO', 'name' => 'Pro Plan', 'finalUnitPrice' => 49.99, 'quantity' => 1]);
$axitrace->track($event);

// or through the helper's $params
$axitrace->startTrial('Pro Plan', [
    'trial_value' => 49.99,
    'trial_currency' => 'USD',
    'eventSalt' => 'trial-' . $accountId,
    'products' => [['sku' => 'PLAN-PRO', 'name' => 'Pro Plan', 'finalUnitPrice' => 49.99, 'quantity' => 1]],
]);
Axitrace._instance.track('start_trial', {
    plan_name: 'Pro Plan',
    trial_value: 49.99,
    trial_currency: 'USD',
    products: [{ sku: 'PLAN-PRO', name: 'Pro Plan', finalUnitPrice: 49.99, quantity: 1 }]
});

The full rules and the HTTP API body are on the Leads page.

Server-Enriched Fields

The following fields are automatically added by the server:

Field Description
ip Client IP address (extracted from X-Forwarded-For, CF-Connecting-IP, etc.)
userAgent Browser User-Agent string
timestamp Server timestamp (ISO 8601 format)

Examples

JavaScript SDK

// Basic trial start - fires Facebook StartTrial pixel (TikTok skipped)
Axitrace._instance.track('start_trial', {
    plan_name: 'Pro',
    trial_period_days: 14
});

// Detailed trial start with value for Facebook optimization
Axitrace._instance.track('start_trial', {
    plan_name: 'Enterprise',
    trial_period_days: 30,
    trial_value: 299.00,
    trial_currency: 'USD',
    trial_type: 'free',
    billing_cycle: 'annual',
    predicted_ltv: 3588.00
});

Server-Side (cURL)

# Full trial start with customer data for Facebook CAPI
curl -X POST https://stat.axitrace.com/v1/start_trial \
  -u "sk_live_YOUR_SECRET_KEY:" \
  -H "Content-Type: application/json" \
  -d '{
    "client_id": "value-from-vt_vid-cookie",
    "user_id": "user-12345",
    "session_id": "value-from-vt_sid-cookie",
    "plan_name": "Enterprise",
    "trial_period_days": 30,
    "trial_value": 299.00,
    "trial_currency": "USD",
    "params": {
        "trial_type": "free",
        "billing_cycle": "annual",
        "predicted_ltv": 3588.00,
        "first_name": "John",
        "last_name": "Doe",
        "phone": "+14155551234",
        "city": "San Francisco",
        "state": "CA",
        "zip": "94102",
        "country": "US",
        "fbp": "fb.1.1234567890.987654321",
        "fbc": "fb.1.1234567890.AbCdEfGhIjKl"
    }
  }'

Server-Side (AxiTrace PHP SDK)

<?php
use AxiTrace\AxiTraceClient;
use AxiTrace\Model\Event\StartTrialEvent;

$client = new AxiTraceClient('sk_live_YOUR_SECRET_KEY');

// Create start trial event - plan_name is required by the PHP SDK
$event = new StartTrialEvent('Enterprise');

// Set user identifiers (from SDK cookies)
$event->setClientId($_COOKIE['vt_vid'] ?? '');
$event->setUserId((string)$user->getId());
$event->setSessionId($_COOKIE['vt_sid'] ?? '');

// Set trial details
$event->setTrialPeriodDays(30);
$event->setTrialValue(299.00, 'USD');

// Optional: Add Facebook CAPI data
$event->setPhone('+14155551234');
$event->setFirstName('John');
$event->setLastName('Doe');
$event->setFbp($_COOKIE['_fbp'] ?? '');
$event->setFbc($_COOKIE['_fbc'] ?? '');

// Optional: Add custom params (predicted_ltv should go in params)
$event->setParams([
    'trial_type' => 'free',
    'billing_cycle' => 'annual',
    'predicted_ltv' => 3588.00,
]);

$response = $client->track($event);
// $response['eventId'] = "a1b2c3d4-..."
PHP SDK Note: predicted_ltv and email

The PHP SDK's setPredictedLtv() and setEmail() methods place these values at the top level of the request body, and that is where the backend reads them - StartTrialEvent carries both fields. Send the customer's e-mail whenever you have it: it is the single strongest Facebook CAPI match key, and it is hashed before it leaves AxiTrace. Passing predicted_ltv through setParams() works just as well.

Server-Side (PHP - raw cURL)

<?php
// Trial signup handler - called after trial is provisioned
$secretKey = getenv('AXITRACE_SECRET_KEY');

// Read AxiTrace SDK cookies - CRITICAL for user profile linking
$visitorId = $_COOKIE['vt_vid'] ?? null;
$sessionId = $_COOKIE['vt_sid'] ?? null;

// Read Facebook cookies for CAPI
$fbp = $_COOKIE['_fbp'] ?? null;
$fbc = $_COOKIE['_fbc'] ?? null;

// Get user and plan data from your application
$user = getCurrentUser();
$plan = getPlan($planId);

// Calculate predicted LTV based on your model
$predictedLtv = $plan->getMonthlyPrice() * 12 * 0.7; // Example: 70% of annual value

$data = [
    'client_id' => $visitorId,
    'user_id' => (string)$user->getId(),
    'session_id' => $sessionId,
    'plan_name' => $plan->getName(),
    'trial_period_days' => $plan->getTrialDays(),
    'trial_value' => $plan->getMonthlyPrice(),
    'trial_currency' => 'USD',
    'params' => array_filter([
        'trial_type' => 'free',
        'billing_cycle' => $plan->getBillingCycle(),
        'predicted_ltv' => $predictedLtv,
        'first_name' => $user->getFirstName(),
        'last_name' => $user->getLastName(),
        'phone' => $user->getPhone(),
        'city' => $user->getCity(),
        'state' => $user->getState(),
        'zip' => $user->getZip(),
        'country' => $user->getCountry(),
        'fbp' => $fbp,
        'fbc' => $fbc,
    ]),
];

// Remove null values
$data = array_filter($data, fn($v) => $v !== null);

$ch = curl_init('https://stat.axitrace.com/v1/start_trial');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_USERPWD => $secretKey . ':',
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'User-Agent: MyApp/1.0'
    ],
    CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $result = json_decode($response, true);
    // Trial tracked: $result['eventId']
}

Server-Side (Python)

import os
import requests
from flask import request

secret_key = os.environ.get('AXITRACE_SECRET_KEY')

def track_trial_start(user, plan):
    # Read AxiTrace SDK cookies - CRITICAL for user profile linking
    visitor_id = request.cookies.get('vt_vid')
    session_id = request.cookies.get('vt_sid')

    # Read Facebook cookies for CAPI
    fbp = request.cookies.get('_fbp')
    fbc = request.cookies.get('_fbc')

    # Calculate predicted LTV
    predicted_ltv = plan.monthly_price * 12 * 0.7  # Example model

    data = {
        'client_id': visitor_id,
        'user_id': str(user.id),
        'session_id': session_id,
        'plan_name': plan.name,
        'trial_period_days': plan.trial_days,
        'trial_value': float(plan.monthly_price),
        'trial_currency': 'USD',
        'params': {
            'trial_type': 'free',
            'billing_cycle': plan.billing_cycle,
            'predicted_ltv': predicted_ltv,
            'first_name': user.first_name,
            'last_name': user.last_name,
            'phone': user.phone,
            'city': user.city,
            'state': user.state,
            'zip': user.zip_code,
            'country': user.country,
            'fbp': fbp,
            'fbc': fbc,
        }
    }

    # Remove None values from params
    data['params'] = {k: v for k, v in data['params'].items() if v}

    response = requests.post(
        'https://stat.axitrace.com/v1/start_trial',
        auth=(secret_key, ''),
        headers={
            'Content-Type': 'application/json',
            'User-Agent': 'MyApp/1.0'
        },
        json=data
    )

    if response.status_code == 200:
        result = response.json()
        return result['eventId']

    return None

Response

Success Response (200 OK)

{
    "success": true,
    "eventId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "action": "start_trial"
}

Error Responses

Status Error Description
400 at least one of client_id, user_id, or session_id is required No user identifier provided
400 trial_value must be >= 0 Negative trial value provided
400 trial_period_days must be >= 0 Negative trial period provided
401 unauthorized Invalid or missing API key

Integration Examples

Stripe Subscription Trial

<?php
// After creating Stripe subscription with trial
$subscription = \Stripe\Subscription::create([
    'customer' => $customerId,
    'items' => [['price' => $priceId]],
    'trial_period_days' => 14,
]);

if ($subscription->status === 'trialing') {
    $price = \Stripe\Price::retrieve($priceId);
    $product = \Stripe\Product::retrieve($price->product);

    $data = [
        'client_id' => $_COOKIE['vt_vid'] ?? null,
        'user_id' => $customerId,
        'plan_name' => $product->name,
        'trial_period_days' => 14,
        'trial_value' => $price->unit_amount / 100,
        'trial_currency' => strtoupper($price->currency),
        'params' => [
            'billing_cycle' => $price->recurring->interval,
            'stripe_subscription_id' => $subscription->id,
        ],
    ];

    // Track to AxiTrace
    trackAxitraceStartTrial($data);
}

Laravel / Cashier

<?php

namespace App\Listeners;

use Laravel\Cashier\Events\WebhookReceived;
use Illuminate\Support\Facades\Http;

class TrackTrialStart
{
    public function handle(WebhookReceived $event)
    {
        if ($event->payload['type'] !== 'customer.subscription.created') {
            return;
        }

        $subscription = $event->payload['data']['object'];

        if ($subscription['status'] !== 'trialing') {
            return;
        }

        $user = User::where('stripe_id', $subscription['customer'])->first();
        if (!$user) return;

        $plan = Plan::where('stripe_price_id', $subscription['items']['data'][0]['price']['id'])->first();

        Http::withBasicAuth(config('services.axitrace.secret_key'), '')
            ->post('https://stat.axitrace.com/v1/start_trial', [
                'user_id' => (string)$user->id,
                'plan_name' => $plan->name,
                'trial_period_days' => $subscription['trial_end']
                    ? (int)(($subscription['trial_end'] - $subscription['trial_start']) / 86400)
                    : 14,
                'trial_value' => $plan->price / 100,
                'trial_currency' => 'USD',
                'params' => [
                    'first_name' => $user->first_name,
                    'last_name' => $user->last_name,
                    'billing_cycle' => $plan->billing_interval,
                ],
            ]);
    }
}

Best Practices

  • Track after provisioning - Fire the event after the trial is actually created in your system
  • Include plan details - Always pass plan_name and trial_period_days for accurate analytics
  • Set trial value - Include trial_value for Facebook CAPI value-based optimization
  • Calculate predicted LTV - If you have a model, pass predicted_ltv in params for better ad optimization
  • Link to browser session - Pass SDK cookie values to connect trials with browsing behavior
  • Pass Facebook cookies - Include _fbp and _fbc for better CAPI matching
  • Track from webhooks - For payment processors like Stripe, track from webhooks for reliability
  • Don't double-track - Choose either JS SDK or server-side for each event. Sending both creates duplicate events.
Trial-to-Paid Conversion Analysis

Start Trial events enable powerful conversion analysis. AxiTrace helps you measure:

  • Trial-to-paid conversion rates by traffic source
  • Which campaigns drive the highest quality trial signups
  • Time from first visit to trial start
  • Trial conversion rates by plan type
  • Impact of trial length on conversion rates
  • ROI of ad spend based on predicted LTV