Skip to content
DocsIntegrationsJoomla / VirtueMart Integration
Integrations

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.

Difficulty: Easy

Add one code snippet to your template and you're ready to go. VirtueMart e-commerce tracking is automatic.

✓ Joomla 3.x & 4.x

Full compatibility with all modern Joomla versions

✓ VirtueMart 3.x & 4.x

Automatic e-commerce event tracking

Quick Installation

Step 1: Access Template Files

Navigate to your Joomla template directory. The most common locations are:

text
Joomla 4.x:
/templates/YOUR_TEMPLATE/index.php

Joomla 3.x:
/templates/YOUR_TEMPLATE/index.php

For child templates:
/templates/YOUR_TEMPLATE_child/index.php

Step 2: Add CONSETO Script

Add the following code before the closing </head> tag:

php
<!-- 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>
Joomla 4.x Note

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:

  1. Go to Extensions → Modules → New
  2. Select Custom module type
  3. Set position to head or debug
  4. Enable "Prepare Content" option
  5. Paste the script code in the content area
  6. Set Show Title: Hide
  7. 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

EventVirtueMart Page/ActionDetection Method
view_itemProduct detail pageURL contains productdetails or flypage
view_categoryCategory listingURL contains category or virtuemart
add_to_cartAdd to cart button clickForm submission with addtocart
view_cartCart pageURL contains cart
begin_checkoutCheckout startURL contains checkout
purchaseOrder confirmationURL 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
<?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
<?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

OptionTypeDescription
clientIdstringYour unique CONSETO client ID (required)
languagestringBanner language: sk, cs, en, de, pl, hu
themestringdark or light theme
autoTrackEcommercebooleanAuto-detect VirtueMart events (default: true)
ga4stringGoogle Analytics 4 ID (G-XXXXXXX)
gtmstringGoogle Tag Manager ID (GTM-XXXXXX)
metaPixelstringMeta/Facebook Pixel ID
debugbooleanEnable console logging for testing

Troubleshooting

Banner not showing?
  • Check that the script is loaded (Network tab in browser DevTools)
  • Verify your clientId is correct
  • Ensure JavaScript is not blocked by other extensions
  • Check for console errors in browser DevTools
E-commerce events not tracking?
  • Enable debug: true to see console logs
  • VirtueMart SEF URLs must be enabled for detection
  • Custom VirtueMart themes may need manual integration
PHP syntax error?
  • 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:

  1. Clear your browser cache and cookies
  2. Visit your website - the consent banner should appear
  3. Accept cookies and check the CONSETO dashboard for the visit
  4. Browse to a product page - view_item event should fire
  5. Add a product to cart - add_to_cart event should fire
  6. Complete a test purchase - purchase event should fire
Pro Tip

Use debug: true during testing to see all events in your browser console. Remove it before going live.

Documentation — CONSETO | CONSETO