client/lib/analytics/ad-tracking.js
function recordOrderInNanigans( cart, orderId ) {
	if ( ! isAdTrackingAllowed() || ! isNanigansEnabled ) {
		return;
	}

	const paidProducts = cart.products.filter( product => product.cost >= 0.01 );

	if ( paidProducts.length === 0 ) {
		debug( 'recordOrderInNanigans: Skip cart because it has ONLY <0.01 products' );
		return;
	}

	debug( 'recordOrderInNanigans: Record purchase' );

	const productPrices = paidProducts.map( product => product.cost * 100 ); // VALUE is in cents, [ 0, 9600 ]
	const eventDetails = {
		sku: paidProducts.map( product => product.product_slug ), // [ 'blog_domain', 'plan_premium' ]
		qty: paidProducts.map( () => 1 ), // [ 1, 1 ]
		currency: cart.currency,
		unique: orderId, // unique transaction id
	};

	const eventStruct = [
		'purchase', // EVENT_TYPE
		'main', // EVENT_NAME
		productPrices,
		eventDetails,
	];

	if ( ! isNanigansConfigured ) {
		setupNanigansGlobal();
		loadScript( NANIGANS_SCRIPT_URL );
	}

	debug( 'Nanigans push:', eventStruct );
	window.NaN_api.push( eventStruct ); // NaN api is either an array that supports push, either the real Nanigans API
}
function recordOrderInNanigans( cart, orderId ) {
	if ( ! isAdTrackingAllowed() || ! isNanigansEnabled ) {
		return;
	}

	const paidProducts = cart.products.filter( product => product.cost >= 0.01 );

	if ( paidProducts.length === 0 ) {
		debug( 'recordOrderInNanigans: Skip cart because it has ONLY <0.01 products' );
		return;
	}

	debug( 'recordOrderInNanigans: Record purchase' );

	const productPrices = paidProducts.map( product => product.cost * 100 ); // VALUE is in cents, [ 0, 9600 ]
	const eventDetails = {
		sku: paidProducts.map( product => product.product_slug ), // [ 'blog_domain', 'plan_premium' ]
		qty: paidProducts.map( () => 1 ), // [ 1, 1 ]
		currency: cart.currency,
		unique: orderId, // unique transaction id
	};

	const eventStruct = [
		'purchase', // EVENT_TYPE
		'main', // EVENT_NAME
		productPrices,
		eventDetails,
	];

	if ( ! isNanigansConfigured ) {
		setupNanigansGlobal();
		loadScript( NANIGANS_SCRIPT_URL );
	}

	debug( 'Nanigans push:', eventStruct );
	window.NaN_api.push( eventStruct ); // NaN api is either an array that supports push, either the real Nanigans API
}
Records an order in Nanigans. If nanigans is not already loaded and configured, it configures it now (delayed load
until the moment when we actually need this pixel).

@param {Object} cart - cart as `CartValue` object
@param {Number} orderId - the order id
@returns {void}