FauryaFaurya
Revenue attribution

WooCommerce

Track and attribute revenue in Faurya for WooCommerce.

Faurya can automatically attribute revenue to sessions, campaigns, and sources by connecting your payment flow to your Faurya site. This guide shows the safest, most reliable way to do that with WooCommerce.

What “revenue attribution” means in Faurya

When a visitor lands on your site, the Faurya script assigns a Visitor ID and Session ID. When the visitor starts checkout, you pass those IDs (or the Faurya attribution token) into your payment provider. When the payment succeeds, your server (or webhook handler) confirms the payment and notifies Faurya. Faurya then ties the purchase back to the original session and attributes revenue to the right channel.

WordPress + WooCommerce setup

WooCommerce attribution usually uses one of these approaches:

  • Thank you page callback (works, but less reliable than webhooks)
  • Payment gateway webhook (recommended if available)
  • WooCommerce hooks on order_status_completed / payment_complete
  1. Ensure Faurya script runs on the storefront (captures visitor/session)
  2. On add-to-cart / checkout, store attribution token in Woo session or as order meta
  3. On payment_complete, send the order total + attribution to Faurya

Example (plugin-style pseudo code)

// In your WooCommerce plugin
add_action('woocommerce_checkout_update_order_meta', function($order_id) {
  if (!empty($_POST['fa_attribution_token'])) {
    update_post_meta($order_id, 'fa_attribution_token', sanitize_text_field($_POST['fa_attribution_token']));
  }
});

add_action('woocommerce_payment_complete', function($order_id) {
  $token = get_post_meta($order_id, 'fa_attribution_token', true);
  $order = wc_get_order($order_id);

  // POST to your Faurya server endpoint (recommended) or directly to Faurya API
});

Approach B: gateway webhooks

If your payment gateway provides webhooks, validate them and map the gateway event to the WooCommerce order ID. Then record revenue to Faurya (idempotent).

Idempotency (do this to avoid double counting)

Always make your revenue writes idempotent:

  • Use a unique orderId from your DB or
  • Use the provider’s unique payment/transaction ID as the idempotency key
  • Store a “revenue_recorded_at” timestamp on your order row so repeated webhook deliveries don’t duplicate revenue

Troubleshooting

Revenue shows as “unattributed”:

  • Make sure you are passing faSessionId or faAttributionToken from the browser to your server when you create checkout.
  • Confirm your checkout/session metadata includes that value.
  • Confirm your webhook handler reads it back and sends it to Faurya.

Revenue is duplicated:

  • Ensure you’re not recording revenue both on “return URL” and on webhook.
  • Add idempotency using orderId / provider transaction ID.

Currency or amount looks wrong:

  • Decide one convention (minor units recommended) and keep it consistent.
  • Always store currency codes in ISO 4217 (USD/INR/EUR).

On this page