WordPress
Add Loamly to your WordPress site
WordPress powers over 40% of the web, and Loamly integrates easily using either a plugin or direct theme editing. Choose the method that works best for your setup.
Using a plugin (recommended)
The easiest way to add Loamly to WordPress is with a header/footer plugin. We recommend WPCode (formerly Insert Headers and Footers):
- Go to Plugins → Add New
- Search for "WPCode"
- Install and activate the plugin
- Go to Code Snippets → Header & Footer
- In the Header section, paste:
<script
src="https://app.loamly.ai/t.js?d=yourdomain.com"
defer
></script>- Click Save Changes
Other plugin options
- Header Footer Code Manager
- Simple Custom CSS and JS
- Any plugin that lets you add code to the header
Editing your theme
If you prefer not to use a plugin, you can add the script directly to your theme:
Method 1: Theme Customizer
Some themes include a "Custom Code" section:
- Go to Appearance → Customize
- Look for Additional CSS/JS or Custom Code
- Add the Loamly script to the header section
- Publish your changes
Method 2: Edit header.php
Use a child theme
- Go to Appearance → Theme File Editor
- Select your theme and open
header.php - Find the
</head>tag - Paste the script just before it
- Click Update File
Method 3: Using functions.php
Add this to your child theme's functions.php:
// Add Loamly tracking script
function add_loamly_tracking() {
?>
<script
src="https://app.loamly.ai/t.js?d=yourdomain.com"
defer
></script>
<?php
}
add_action('wp_head', 'add_loamly_tracking');Enable AI verification (recommended)
The client-side script tracks page views, but to unlock the full power of Loamly you need server-side setup. This enables AI bot crawl detection, RFC 9421 signature verification, bot-to-click temporal matching, and prompt-to-crawl correlation with your Intelligence data. Without it, you miss the connection between AI bots crawling your site and the humans who visit after.
See the AI Visitor Verification guide for setup instructions.
Verify installation
- Visit your WordPress site in a new browser tab
- Right-click → View Page Source
- Search for "loamly" to confirm the script is in the head
- Check your Loamly dashboard for the visit
WooCommerce tracking
If you use WooCommerce, you can track purchases by adding code to your theme or using the WPCode plugin:
// Add to functions.php or as a WPCode snippet
add_action('woocommerce_thankyou', 'loamly_track_purchase');
function loamly_track_purchase($order_id) {
$order = wc_get_order($order_id);
if (!$order) return;
?>
<script>
if (window.loamly) {
window.loamly.event('purchase', {
order_id: '<?php echo esc_js($order_id); ?>',
total: <?php echo esc_js($order->get_total()); ?>,
currency: '<?php echo esc_js($order->get_currency()); ?>',
items_count: <?php echo esc_js($order->get_item_count()); ?>
});
}
</script>
<?php
}Revenue attribution
Need help? Email hello@loamly.ai