WP Simple Pay Documentation

Documentation, Reference Materials, and Tutorials for WP Simple Pay

Tips & Tricks

Join our Newsletter

Please enable JavaScript in your browser to complete this form.
Get tips, tricks, and resources delivered directly to your mailbox.
WP Simple Pay
Save 70%!

How to add conversion tracking codes to WP Simple Pay

The following code will execute a script the first time a payment confirmation is viewed.

<?php	
/**
 * @link https://library.wpcode.com/snippet/j57gg315/
 */

add_action(
	'simpay_payment_receipt_viewed',
	/**
	 * Runs the first time the payment confirmation page is viewed.
	 * 
	 * @param array<string, mixed> $payment_confirmation_data
	 */

	
	function( $payment_confirmation_data ) {
		// Payment customer data (not used in this example).
		$customer = $payment_confirmation_data['customer'];

		// One-time payment data.
		$payment = current( $payment_confirmation_data['paymentintents'] );

		printf(
			'<script>fbq("track", "Purchase", {currency: "%s", value: "%s"});</script>',
			$payment->currency,
			$payment->amount / 100
		);
	}
);

Still have questions? We’re here to help!

Last Modified:

Start Accepting Payments Today

Start accepting one-time and recurring payments or donations on your WordPress website.