Platform Integration¶
This guide covers installing Dxtra Tag Manager on popular platforms and frameworks. The core installation is the same everywhere -- add the script tag to your site's <head> section:
Platform-specific instructions are below.
WordPress¶
Plugin Method (Recommended)¶
- Install and activate the Insert Headers and Footers plugin
- Navigate to Settings > Insert Headers and Footers
- Paste the Dxtra script tag in the Header section
- Click Save
Theme Method¶
Add to your child theme's functions.php:
function dxtra_tag_manager() {
if (!is_admin()) {
?>
<script src="https://tagmanager-edge.dxtra.ai/tm.js" async></script>
<?php
}
}
add_action('wp_head', 'dxtra_tag_manager');
WooCommerce E-commerce Tracking¶
Track product views and purchases with Dxtra Analytics:
function dxtra_woocommerce_tracking() {
if (!function_exists('is_woocommerce')) return;
?>
<script>
<?php if (is_product()): global $product; ?>
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('product_view', {
product_id: '<?php echo $product->get_id(); ?>',
product_name: '<?php echo esc_js($product->get_name()); ?>',
product_price: <?php echo $product->get_price(); ?>
});
}
<?php endif; ?>
<?php if (is_checkout() && is_order_received_page()):
$order = wc_get_order(get_query_var('order-received'));
if ($order): ?>
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('purchase', {
transaction_id: '<?php echo $order->get_order_number(); ?>',
value: <?php echo $order->get_total(); ?>,
currency: '<?php echo $order->get_currency(); ?>'
});
}
<?php endif; endif; ?>
</script>
<?php
}
add_action('wp_head', 'dxtra_woocommerce_tracking');
Shopify¶
- From Shopify admin, go to Online Store > Themes
- Click Actions > Edit code on your active theme
- Open
theme.liquidin the Layout section - Add the Dxtra script immediately after the
<head>tag - Click Save
Shopify E-commerce Tracking¶
Add to theme.liquid for automatic product and purchase tracking:
<script>
{% if template contains 'product' %}
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('product_view', {
product_id: {{ product.id }},
product_name: '{{ product.title | escape }}',
product_price: {{ product.price | divided_by: 100.0 }}
});
}
{% endif %}
{% if template contains 'thank_you' %}
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('purchase', {
transaction_id: '{{ order.order_number }}',
value: {{ order.total_price | divided_by: 100.0 }},
currency: '{{ order.currency }}'
});
}
{% endif %}
</script>
Squarespace¶
Note
Code injection requires a Business or Commerce plan.
- Go to Settings > Advanced > Code Injection
- Paste the Dxtra script tag in the Header section
- Click Save
Wix¶
Note
Custom code requires a paid subscription plan.
- Go to Settings > Custom Code > Advanced
- Click + Add Custom Code
- Paste the Dxtra script tag
- Set placement to All Pages, location to Head
- Click Apply
React¶
Add the script tag to your public/index.html <head>, or load it programmatically:
// App.js
import { useEffect } from 'react';
function App() {
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://tagmanager-edge.dxtra.ai/tm.js';
script.async = true;
document.head.appendChild(script);
}, []);
return <div className="App">{/* Your app */}</div>;
}
For React Router SPA page tracking:
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
function usePageTracking() {
const location = useLocation();
useEffect(() => {
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('page_view', {
page_location: window.location.href,
page_title: document.title,
page_path: location.pathname
});
}
}, [location]);
}
Next.js¶
// pages/_app.js
import { useEffect } from 'react';
import { useRouter } from 'next/router';
function MyApp({ Component, pageProps }) {
const router = useRouter();
useEffect(() => {
const script = document.createElement('script');
script.src = 'https://tagmanager-edge.dxtra.ai/tm.js';
script.async = true;
document.head.appendChild(script);
}, []);
useEffect(() => {
const handleRouteChange = (url) => {
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('page_view', {
page_location: window.location.href,
page_path: url
});
}
};
router.events.on('routeChangeComplete', handleRouteChange);
return () => router.events.off('routeChangeComplete', handleRouteChange);
}, [router.events]);
return <Component {...pageProps} />;
}
Vue.js¶
// main.js
const script = document.createElement('script');
script.src = 'https://tagmanager-edge.dxtra.ai/tm.js';
script.async = true;
document.head.appendChild(script);
For Vue Router page tracking:
// router/index.js
router.afterEach((to) => {
if (window.dxtraAnalytics) {
window.dxtraAnalytics.track('page_view', {
page_location: window.location.href,
page_path: to.path
});
}
});
Angular¶
// dxtra.service.ts
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class DxtraService {
constructor() {
const script = document.createElement('script');
script.src = 'https://tagmanager-edge.dxtra.ai/tm.js';
script.async = true;
document.head.appendChild(script);
}
trackEvent(event: string, data: Record<string, unknown>): void {
if ((window as any).dxtraAnalytics) {
(window as any).dxtraAnalytics.track(event, data);
}
}
}
Verification¶
After installing on any platform, verify the integration:
- Open your site in a browser
- Add
#dxtra-debugto the URL to activate the debug overlay - Confirm the Tag Manager loads and events fire
- Check the Dxtra analytics dashboard for incoming data
Performance Optimization¶
Add DNS prefetching for faster script loading:
<link rel="dns-prefetch" href="//tagmanager-edge.dxtra.ai">
<link rel="preconnect" href="https://tagmanager-edge.dxtra.ai">
Continue to Debugging for troubleshooting Tag Manager installations.