client/lib/analytics/ad-tracking.js
function recordProduct( product, orderId ) {
	if ( ! isAdTrackingAllowed() ) {
		debug( 'recordProduct: [Skipping] ad tracking is not allowed' );
		return;
	}

	if ( TRACKING_STATE_VALUES.LOADED !== trackingState ) {
		loadTrackingScripts( recordProduct.bind( null, product, orderId ) );
		return;
	}

	const isJetpackPlan = productsValues.isJetpackPlan( product );

	if ( isJetpackPlan ) {
		debug( 'Recording Jetpack purchase', product );
	} else {
		debug( 'Recording purchase', product );
	}

	const currentUser = user.get();
	const userId = currentUser ? hashPii( currentUser.ID ) : 0;

	try {
		// Google Analytics
		const item = {
			currency: product.currency,
			id: orderId,
			name: product.product_slug,
			price: product.cost,
			sku: product.product_slug,
			quantity: 1,
		};
		debug( 'recordProduct: ga ecommerce add item', item );
		window.ga( 'ecommerce:addItem', item );

		// Google AdWords
		if ( isAdwordsEnabled ) {
			if ( window.google_trackConversion ) {
				let googleConversionId, googleConversionLabel;

				if ( isJetpackPlan ) {
					googleConversionId = ADWORDS_CONVERSION_ID_JETPACK;
					googleConversionLabel = TRACKING_IDS.googleConversionLabelJetpack;
				} else {
					googleConversionId = ADWORDS_CONVERSION_ID;
					googleConversionLabel = TRACKING_IDS.googleConversionLabel;
				}

				window.google_trackConversion( {
					google_conversion_id: googleConversionId,
					google_conversion_label: googleConversionLabel,
					google_conversion_value: product.cost,
					google_conversion_currency: product.currency,
					google_custom_params: {
						product_slug: product.product_slug,
						user_id: userId,
						order_id: orderId,
					},
					google_remarketing_only: false,
				} );
			}
		}
	} catch ( err ) {
		debug( 'Unable to save purchase tracking data', err );
	}
}
function recordProduct( product, orderId ) {
	if ( ! isAdTrackingAllowed() ) {
		debug( 'recordProduct: [Skipping] ad tracking is not allowed' );
		return;
	}

	if ( TRACKING_STATE_VALUES.LOADED !== trackingState ) {
		loadTrackingScripts( recordProduct.bind( null, product, orderId ) );
		return;
	}

	const isJetpackPlan = productsValues.isJetpackPlan( product );

	if ( isJetpackPlan ) {
		debug( 'Recording Jetpack purchase', product );
	} else {
		debug( 'Recording purchase', product );
	}

	const currentUser = user.get();
	const userId = currentUser ? hashPii( currentUser.ID ) : 0;

	try {
		// Google Analytics
		const item = {
			currency: product.currency,
			id: orderId,
			name: product.product_slug,
			price: product.cost,
			sku: product.product_slug,
			quantity: 1,
		};
		debug( 'recordProduct: ga ecommerce add item', item );
		window.ga( 'ecommerce:addItem', item );

		// Google AdWords
		if ( isAdwordsEnabled ) {
			if ( window.google_trackConversion ) {
				let googleConversionId, googleConversionLabel;

				if ( isJetpackPlan ) {
					googleConversionId = ADWORDS_CONVERSION_ID_JETPACK;
					googleConversionLabel = TRACKING_IDS.googleConversionLabelJetpack;
				} else {
					googleConversionId = ADWORDS_CONVERSION_ID;
					googleConversionLabel = TRACKING_IDS.googleConversionLabel;
				}

				window.google_trackConversion( {
					google_conversion_id: googleConversionId,
					google_conversion_label: googleConversionLabel,
					google_conversion_value: product.cost,
					google_conversion_currency: product.currency,
					google_custom_params: {
						product_slug: product.product_slug,
						user_id: userId,
						order_id: orderId,
					},
					google_remarketing_only: false,
				} );
			}
		}
	} catch ( err ) {
		debug( 'Unable to save purchase tracking data', err );
	}
}
Recorders an individual product purchase conversion

@param {Object} product - the product
@param {Number} orderId - the order id
@returns {void}