Please follow these 3 instruction steps to set up the
Capitula campaign for WordPress website
STEP
You need to add the provided CDN code to your website’s header.
Log in to your WordPress admin dashboard.
Go to Appearance > Theme Editor.
Select the header.php file from the right panel.
Insert the CDN code just before the closing </head>
tag:
The below code is jQuery CDN link if you already have jQuery in your theme ignore this, if not please add that first.
<script type="text/javascript">if(typeof jQuery == 'undefined'){document.write('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></'+'script>');}</script>
After adding the jQuery CDN link please add this Capitula CDN link
<script>document.write("<script type='text/javascript' src='https://api.capitula.co.uk/assets/js/capitula_cdn.js?v=" + Date.now() + "'><\/script>");</script>
Click Update File.
STEP
Register CPL
Go to the Thank You or Confirmation page after registration.
Wrap the registered email using <capitula_email>registered email here</capitula_email>
This can also be done for any subscription form where the user enters an email.
If you are using any email subscription field/widget do the same on the confirmation message make sure to wrap the email address.
STEP
Wrap Total Price and Transaction ID in WooCommerce
To track the Total Price and Transaction ID on the WooCommerce Order Confirmation page, follow these steps:
Log in to your WordPress admin dashboard.
Go to Appearance > Theme Editor.
Select the functions.php
file from the theme’s files.
Add a function to modify the WooCommerce Order Confirmation page:
// Function to add hidden Capitula tags to the WooCommerce thank-you page
function add_hidden_capitula_order_id_tags($order_id) {
$order = wc_get_order($order_id);
if ($order) {
// Get the WooCommerce Order ID directly
$order_number = $order->get_order_number();
$total_price = $order->get_total();
// Output hidden Capitula tags for tracking
echo "<div style='display: none;'>";
echo "<capitula_trans>{$order_number}</capitula_trans>";
echo "<capitula_pay>{$total_price}</capitula_pay>";
echo "</div>";
}
}
// Hook into the WooCommerce thank-you page after order details
add_action('woocommerce_order_details_after_order_table', 'add_hidden_capitula_order_id_tags');
// Function to add hidden Capitula tags to the WooCommerce thank-you page
function add_hidden_capitula_order_id_tags($order_id) {
$order = wc_get_order($order_id);
if ($order) {
// Get the WooCommerce Order ID directly
$order_number = $order->get_order_number();
$total_price = $order->get_total();
// Output hidden Capitula tags for tracking
echo "<div style='display: none;'>";
echo "<capitula_trans>{$order_number}</capitula_trans>";
echo "<capitula_pay>{$total_price}</capitula_pay>";
echo "</div>";
}
}
// Hook into the WooCommerce thank-you page after order details
add_action('woocommerce_order_details_after_order_table', 'add_hidden_capitula_order_id_tags');
Click Update File.
This will automatically add the <capitula_pay>
and <capitula_trans>
tags to the WooCommerce Thank You page with the respective values.
These steps will help you integrate the Capitula system into your WordPress WooCommerce site efficiently.