Egenverk Conversion Relay · Documentation

Reference

v1.7.0WP 6.5+PHP 7.4+Updated

Constants and environment variables

NameWhat
EGENVERK_CONVERSION_RELAY_API_KEYThe Conversions API key. As a constant in wp-config.php or as an environment variable. Takes precedence over the saved key and is never shown in the admin.
CONVERT_RELAY_API_KEYThe former name, still read. Rename it to the new name.

The order is constant, then an environment variable of the same name and, last, the saved key. An explicitly empty value on the server takes precedence over the saved key.

define( 'EGENVERK_CONVERSION_RELAY_API_KEY', 'your-key' );

Filters

Callbacks still registered under the former convert_relay_* names run, but with a deprecation notice. Switch to the names below.

egenverk_conversion_relay_capture_order

Decides whether a paid order counts as a purchase. Arguments:

  • $capture (bool): true, or false when the order is a subscription renewal.
  • $order (WC_Order): the order.

Return false to exclude the order, for example copies made by plugins that duplicate or split orders.

add_filter(
	'egenverk_conversion_relay_capture_order',
	function ( $capture, $order ) {
		if ( $order->get_meta( '_my_copy_of_order' ) ) {
			return false;
		}
		return $capture;
	},
	10,
	2
);

The meta field in the example is only an example. Use the one your own plugin sets on the copies.

egenverk_conversion_relay_allowed_origins

The origins allowed to send the browser's requests to the plugin, such as a refusal of consent. Arguments:

  • $origins (array): origins such as https://example.com, that is scheme, host and any port, without a trailing slash. By default the store's home address and WordPress address.

Return the whole list. An origin must match the request's Origin exactly. A rejected origin is logged as a warning at most once an hour.

add_filter(
	'egenverk_conversion_relay_allowed_origins',
	function ( $origins ) {
		$origins[] = 'https://shop.example.com';
		return $origins;
	}
);

WooCommerce locations

WhatWhere
Settings, validation and deliveryWooCommerce → Settings → Conversion Relay, tabs Settings, Validation & log and Delivery status
LogWooCommerce → Status → Logs, source egenverk-conversion-relay
QueueWooCommerce → Status → Scheduled Actions, group egenverk-conversion-relay

The Plugins screen also has a Settings link to the plugin.

Events

EventFromWhen
page_viewedBrowserPage view
contents_viewedBrowserProduct view
items_addedBrowserAdd to cart
checkout_startedBrowserCheckout started, with the first 50 cart lines
order_createdServerConfirmed purchase

The purchase amount is the order total after discounts, including tax, shipping and fees. Stores with currencies outside ISO 4217 or with fractional quantities are not supported.

Content Security Policy

If the site uses a Content Security Policy, add OpenAI's addresses to the existing one:

script-src  https://bzrcdn.openai.com
connect-src https://bzrcdn.openai.com https://bzr.openai.com
img-src     https://bzr.openai.com

Keep your current nonce or hash policy. unsafe-inline is not needed.

Page cache and CDN

The server reads consent and the ad click from the cookies of requests WooCommerce makes anyway. The page cache and any CDN must therefore not serve cached HTML to requests carrying these cookies, and must pass the cookies through to PHP:

  • wp_woocommerce_session_*
  • woocommerce_items_in_cart
  • wordpress_logged_in_*

Otherwise pages are identical for every guest and can be cached. Purge the page cache after changing settings or updating the plugin.

Resources