Joomla / VirtueMart Integration
Overview
Complete GDPR compliance and analytics for Joomla websites with VirtueMart e-commerce. This guide covers both basic Joomla sites and full VirtueMart store integration.
Add one code snippet to your template and you're ready to go. VirtueMart e-commerce tracking is automatic.
Full compatibility with all modern Joomla versions
Automatic e-commerce event tracking
Quick Installation
Step 1: Access Template Files
Navigate to your Joomla template directory. The most common locations are:
Joomla 4.x:
/templates/YOUR_TEMPLATE/index.php
Joomla 3.x:
/templates/YOUR_TEMPLATE/index.php
For child templates:
/templates/YOUR_TEMPLATE_child/index.phpStep 2: Add CONSETO Script
Add the following code before the closing </head> tag:
<!-- CONSETO GDPR & Analytics -->
<script src="https://www.conseto.io/dist/conseto.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', async function() {
const conseto = await Conseto.init({
clientId: 'YOUR_CLIENT_ID',
language: '<?php echo substr(JFactory::getLanguage()->getTag(), 0, 2); ?>',
theme: 'dark',
autoTrackEcommerce: true,
brandName: '<?php echo JFactory::getConfig()->get("sitename"); ?>',
privacyPolicyUrl: '/privacy-policy',
cookiePolicyUrl: '/cookie-policy'
});
window.conseto = conseto;
});
</script>For Joomla 4.x, use Factory::getLanguage() instead of JFactory::getLanguage()
Alternative: Using Joomla Module
If you prefer not to edit template files, you can use a Custom HTML module:
- Go to Extensions → Modules → New
- Select Custom module type
- Set position to
headordebug - Enable "Prepare Content" option
- Paste the script code in the content area
- Set Show Title: Hide
- Assign to All pages
VirtueMart E-commerce Tracking
CONSETO automatically detects VirtueMart pages and tracks e-commerce events. No additional configuration needed.
Automatic Event Detection
| Event | VirtueMart Page/Action | Detection Method |
|---|---|---|
view_item | Product detail page | URL contains productdetails or flypage |
view_category | Category listing | URL contains category or virtuemart |
add_to_cart | Add to cart button click | Form submission with addtocart |
view_cart | Cart page | URL contains cart |
begin_checkout | Checkout start | URL contains checkout |
purchase | Order confirmation | URL contains thankyou or confirmation |
Enhanced VirtueMart Tracking (Optional)
For more detailed product data in your analytics, add this enhanced tracking to your VirtueMart product template:
<?php
// Add to: /components/com_virtuemart/views/productdetails/tmpl/default.php
// After the product data is loaded
?>
<script>
if (window.conseto) {
window.conseto.track('view_item', {
item_id: '<?php echo $this->product->virtuemart_product_id; ?>',
item_name: '<?php echo addslashes($this->product->product_name); ?>',
price: <?php echo $this->product->prices['salesPrice']; ?>,
currency: '<?php echo $this->currency->currency_code_3; ?>',
item_category: '<?php echo addslashes($this->product->category_name); ?>',
item_brand: '<?php echo addslashes($this->product->mf_name ?? ""); ?>'
});
}
</script>Purchase Tracking on Thank You Page
For accurate purchase tracking, add this to your order confirmation template:
<?php
// Add to: /components/com_virtuemart/views/orders/tmpl/details.php
// Or your custom confirmation template
?>
<script>
if (window.conseto) {
window.conseto.trackConversion('purchase', {
transaction_id: '<?php echo $this->orderDetails["details"]["BT"]->order_number; ?>',
value: <?php echo $this->orderDetails["details"]["BT"]->order_total; ?>,
currency: '<?php echo $this->orderDetails["details"]["BT"]->order_currency; ?>',
items: [
<?php foreach($this->orderDetails['items'] as $item): ?>
{
item_id: '<?php echo $item->virtuemart_product_id; ?>',
item_name: '<?php echo addslashes($item->order_item_name); ?>',
price: <?php echo $item->product_final_price; ?>,
quantity: <?php echo $item->product_quantity; ?>
},
<?php endforeach; ?>
]
});
}
</script>Configuration Options
| Option | Type | Description |
|---|---|---|
clientId | string | Your unique CONSETO client ID (required) |
language | string | Banner language: sk, cs, en, de, pl, hu |
theme | string | dark or light theme |
autoTrackEcommerce | boolean | Auto-detect VirtueMart events (default: true) |
ga4 | string | Google Analytics 4 ID (G-XXXXXXX) |
gtm | string | Google Tag Manager ID (GTM-XXXXXX) |
metaPixel | string | Meta/Facebook Pixel ID |
debug | boolean | Enable console logging for testing |
Troubleshooting
- Check that the script is loaded (Network tab in browser DevTools)
- Verify your
clientIdis correct - Ensure JavaScript is not blocked by other extensions
- Check for console errors in browser DevTools
- Enable
debug: trueto see console logs - VirtueMart SEF URLs must be enabled for detection
- Custom VirtueMart themes may need manual integration
- Ensure you're using the correct PHP syntax for your Joomla version
- Joomla 4.x uses
Factory::namespace - Joomla 3.x uses
JFactory::prefix
Testing Your Integration
Follow these steps to verify everything is working:
- Clear your browser cache and cookies
- Visit your website - the consent banner should appear
- Accept cookies and check the CONSETO dashboard for the visit
- Browse to a product page -
view_itemevent should fire - Add a product to cart -
add_to_cartevent should fire - Complete a test purchase -
purchaseevent should fire
Use debug: true during testing to see all events in your browser console. Remove it before going live.