Platform guides
Step-by-step install of the VitalSentinel tracking scripts on WordPress, WooCommerce, Shopify, Wix, Squarespace, Webflow, Google Tag Manager, Magento, Next.js, Nuxt and HTML sites.
This page shows how to install the VitalSentinel tracking scripts on popular website platforms, step by step. The RUM script feeds RUM Monitoring, and the Web Analytics script feeds Web Analytics. You can install one script or both. Each platform section ends with the common problems on that platform.
Before you start
Copy your snippet from the app first. It is in the onboarding Install tracking step, in domain Settings > Tracking, and in the Install the script side panel of a module page. See Tracking Scripts.
The snippet has two forms. Select the form above the snippet before you click Copy:
- HTML: one
<script>tag for each script. Use it in a header field, a theme file or an HTML template. - Google Tag Manager: the same scripts, built in JavaScript. Use it in Google Tag Manager, and in any website builder that changes the code that you paste.
The examples on this page use YOUR_TRACKING_ID. The snippet that you copy from the app has your real tracking ID and the options that you set. Both scripts use the same tracking ID. Paste the snippet as it is. Only workspace owners and admins can copy the snippet.
The basic HTML snippet for both scripts is:
<script src="https://rum.vitalsentinel.com/rum.js" data-key="YOUR_TRACKING_ID" async></script>
<script src="https://analytics.vitalsentinel.com/analytics.js" data-key="YOUR_TRACKING_ID" async></script>Which platforms get ecommerce tracking
The Web Analytics script finds four shop platforms on its own: Shopify, WooCommerce, Magento and Squarespace. On these platforms, it sends product views, add to cart, cart views, checkout starts and orders. On Shopify and Squarespace, orders need one more step, because their checkout pages do not run the code of your theme or site header. See Shopify ecommerce tracking and Squarespace ecommerce tracking. Events appear in Web Analytics > Ecommerce within minutes of the first shop visit.
On all other platforms, such as Wix, Webflow or a custom store, the Web Analytics script sends no shop events. You can send your own events from your code. Custom events appear under Events and can be goals on Conversions, but they do not give revenue or orders.
In Web Analytics > Ecommerce, the panel Set up shop tracking shows the install place for each platform. It also has a Custom events choice for other stores. See Ecommerce and Web Analytics Script.
WordPress
WordPress has no built-in field for header code. Use a plugin, or add the snippet to your theme. The same methods work with or without WooCommerce.
Install on WordPress with the WPCode plugin
WPCode (listed in the WordPress plugin directory as "WPCode – Insert Headers and Footers") adds a site-wide header field.
- In the WordPress admin, go to Plugins > Add New Plugin.
- Search for "WPCode", then install and activate the plugin.
- Go to Code Snippets > Header & Footer.
- Paste the VitalSentinel snippet in the Header field.
- Click Save Changes.
- If you use a caching plugin, clear its cache.
Other header and footer plugins work the same way. Paste the snippet in the field for the site header, on every page.
Install on WordPress in the theme (functions.php)
Add this code to the functions.php file of your theme. Use a child theme, so that a theme update does not remove the change.
function vitalsentinel_scripts() {
?>
<script src="https://rum.vitalsentinel.com/rum.js" data-key="YOUR_TRACKING_ID" async></script>
<script src="https://analytics.vitalsentinel.com/analytics.js" data-key="YOUR_TRACKING_ID" async></script>
<?php
}
add_action('wp_head', 'vitalsentinel_scripts');You can also paste the snippet in the header.php file of the theme, just before </head>.
Install on WordPress with wp_enqueue_script (WordPress 6.3 and later)
function vitalsentinel_scripts() {
wp_enqueue_script(
'vitalsentinel-rum',
'https://rum.vitalsentinel.com/rum.js',
array(),
null,
array( 'strategy' => 'async' )
);
wp_enqueue_script(
'vitalsentinel-analytics',
'https://analytics.vitalsentinel.com/analytics.js',
array(),
null,
array( 'strategy' => 'async' )
);
}
add_action('wp_enqueue_scripts', 'vitalsentinel_scripts');
function vitalsentinel_add_data_key($tag, $handle) {
if (in_array($handle, ['vitalsentinel-rum', 'vitalsentinel-analytics'])) {
return str_replace(' src=', ' data-key="YOUR_TRACKING_ID" src=', $tag);
}
return $tag;
}
add_filter('script_loader_tag', 'vitalsentinel_add_data_key', 10, 2);The second function adds the data-key attribute, because wp_enqueue_script cannot add it.
Common problems on WordPress
- A caching plugin shows old pages. Clear the page cache of the plugin, and of your host or CDN, after you add the snippet.
- A JavaScript delay or combine setting changes the script. Plugins such as WP Rocket can delay all scripts until the visitor clicks or scrolls. Exclude
rum.vitalsentinel.comandanalytics.vitalsentinel.com. See Tracking Scripts. - A theme update removed the snippet. Code in a parent theme file goes away when the theme updates. Use a plugin or a child theme.
- The snippet is in two places. If you added it with a plugin and in the theme, remove one copy.
WooCommerce
WooCommerce runs on WordPress, so you install the snippet with one of the WordPress methods above. The VitalSentinel setup panel gives two places. Paste the snippet into the header.php file of your theme, just before </head>. Or paste it into a header-scripts plugin such as WPCode, set to run on every page.
WooCommerce ecommerce tracking
The Web Analytics script finds WooCommerce on its own. It sends these events, with no extra setup:
- Product views on product pages
- Add to cart
- Cart views and checkout starts
- Completed orders, from the WooCommerce order received page
The script reads the cart from the page, so the Storage mode does not change what WooCommerce sends. It records an order only when it can read the order ID. Set your store currency in domain Settings > Site setup > Currency, so that revenue always has a currency.
Common problems on WooCommerce
- No orders appear. Make sure that the snippet also runs on the checkout and order received pages. Some plugins let you choose pages: select every page.
- A caching or optimization plugin skips the cart or checkout. Exclude the two VitalSentinel scripts from JavaScript delay, defer and combine settings.
- Revenue has no currency. Your prices probably use a symbol with more than one meaning, for example a plain $. Set the currency in domain Settings > Site setup > Currency. See Currency.
- Ecommerce shows no events at all. Turn on debug mode and look for "Ecommerce platform detected" in the browser console. See Web Analytics Script.
Shopify
Add the snippet to the code of your Shopify theme. For checkout starts and orders, also add a custom pixel in Customer events.
Install on Shopify in the theme code
- In the Shopify admin, go to Online Store > Themes.
- On your current theme, click the ... menu, then click Edit code.
- In the Layout folder, open
theme.liquid. - Paste the snippet just before the closing
</head>tag. - Click Save.
Do not paste the snippet into Customer events. Shopify runs custom pixels in a sandbox, where the snippet does not work. Use the custom pixel from VitalSentinel there.
Shopify ecommerce tracking
The theme snippet tracks product views, add to cart and cart views. Shopify does not run theme code on its checkout and Thank you pages. Thus, checkout starts and orders come from a custom pixel.
To add the custom pixel:
- In VitalSentinel, go to Web Analytics > Ecommerce and click Set up shop tracking.
- Select Shopify.
- Under 2. Orders and checkout: add a custom pixel, copy the Shopify custom pixel code.
- In the Shopify admin, go to Settings > Customer events.
- Click Add custom pixel and enter a name, for example "VitalSentinel".
- Paste the code.
- Click Save, then click Connect.
If your shop already sends product views, open the Ecommerce page and click Shop setup in the page header. The same panel opens, so you can add the Shopify custom pixel.
VitalSentinel makes the pixel for your domain, with your tracking ID in it. The pixel sends a checkout start and each completed order. For an order, it sends the order ID, the total, the subtotal, tax, shipping, the currency and the discount code. It sends no visitor ID, no cart contents, and no name, email, phone or address of the buyer.
The pixel records an order only when it has an order ID and a total. VitalSentinel counts each order ID one time. In the pixel settings of Shopify, under Customer privacy, Shopify decides if visitors must give consent before the pixel runs.
Shopify keeps the cart on the visitor's device. Thus, the theme snippet reads cart items only with Session or Persistent storage. With None, it still counts cart views, but without items, quantities or values. Product views and add to cart work in every storage mode. See Web Analytics Script.
Common problems on Shopify
- You changed or duplicated the theme. The snippet is in the code of one theme. Add it again to the new theme before you publish it.
- Checkout starts or orders are missing. Shopify checkout pages do not use your
theme.liquidfile. Add the custom pixel in Customer events, and make sure that its status is connected. - Cart items have no values. Use Session or Persistent storage, with the visitor's consent.
- The snippet is in the theme and in an app. Remove one copy.
Wix
Wix adds your code in the Custom Code settings. Your site must be published and have a connected domain.
Install on Wix with Custom Code
- In your Wix site dashboard, go to Settings.
- Under Development & integrations, click Custom Code.
- Click + Add Custom Code.
- Paste the VitalSentinel snippet in the text box.
- Enter a name, for example "VitalSentinel".
- Under Add Code to Pages, select All pages, then select the option to load the code once.
- Under Place Code in, select Head.
- Click Apply.
Set Web Analytics to SPA mode on Wix
Wix can change pages without a full page load, so the code loads one time for each visit. In VitalSentinel, set Single page app (SPA) mode to Enabled in domain Settings > Tracking > Web Analytics > Options. Then copy the snippet again and replace it in Wix. The RUM script finds these page changes on its own.
Common problems on Wix
- Web Analytics shows only one page view for each visit. Set Single page app (SPA) mode to Enabled, and replace the snippet.
- You changed the primary domain. Wix deletes custom code when the primary domain changes. Add the snippet again.
- The tracking ID does not reach the script. Use the Google Tag Manager form of the snippet in the Wix text box.
- Ecommerce shows no events. VitalSentinel does not find Wix Stores on its own. Send custom events instead.
Squarespace
Squarespace adds your code in the Code Injection panel. Code injection is available on the Core, Plus, Advanced and some legacy Squarespace plans.
Install on Squarespace with Code Injection
- Open the Code Injection panel. It is in the Website menu, under Pages > Website Tools. You need the Administrator permission.
- Find the Header field. Squarespace adds the code in this field to the
<head>of every page. - Paste the VitalSentinel snippet in the Header field.
- Save the change.
Squarespace ecommerce tracking
The Web Analytics script finds Squarespace Commerce on its own. It tracks product views, add to cart, cart views, checkout starts and orders. The script reads the cart from the page, so the Storage mode does not change what Squarespace sends.
Squarespace checkout runs on its own pages, which do not run the Header field. To record orders, paste the snippet again after checkout:
- Open the Code Injection panel again.
- Paste the VitalSentinel snippet in the Order status page field.
- Paste the VitalSentinel snippet in the Order confirmation page field.
- Save the change.
The script reads orders from the Squarespace order confirmation. It records an order only when it can read an order ID. Without an ID, VitalSentinel cannot prevent double counts, so it drops the order.
Common problems on Squarespace
- There is no Code Injection panel. Your plan does not include code injection, or you do not have the Administrator permission.
- Orders are missing. Make sure that the snippet is in the Order status page and Order confirmation page fields. VitalSentinel records an order only when it can read the order ID after checkout.
- The snippet is in the site header and in a page header. Remove the copy from the page settings.
Webflow
Webflow adds site-wide code in Site settings. Custom code needs a paid Webflow Site plan or a paid Workspace plan.
Install on Webflow with custom code
- In Webflow, open the Site settings of your site.
- Open the Custom code tab.
- Paste the VitalSentinel snippet in the Head code field.
- Save the changes.
- Publish the site.
The code goes live only after you publish. Preview does not send the change to your live site.
Common problems on Webflow
- The script is not on the live site. Publish the site again after you save the code.
- The site is on the free Starter plan. Custom code needs a paid plan.
- You test on the
webflow.iostaging address. Web Analytics accepts hits only from the host of your domain. Test on your own domain. - Ecommerce shows no events. VitalSentinel does not find Webflow Ecommerce on its own. Send custom events instead.
Google Tag Manager
Use the Google Tag Manager form of the snippet. Do not paste the HTML form into Google Tag Manager.
Install with Google Tag Manager
- In VitalSentinel, select Google Tag Manager above the snippet, then click Copy.
- In Google Tag Manager, go to Tags, then click New.
- Click Tag Configuration, then select Custom HTML.
- Paste the snippet into the HTML field.
- Click Triggering, then select the All Pages trigger.
- Save the tag.
- Click Submit, then click Publish.
- Open your site once in a browser.
To test the tag before you publish, click Preview in Google Tag Manager. Tag Assistant then shows the tags that fired and the tags that did not fire.
The Google Tag Manager snippet
The Google Tag Manager snippet looks like this for the RUM script:
<script>
(function () {
var s = document.createElement('script');
s.async = true;
s.src = 'https://rum.vitalsentinel.com/rum.js';
s.setAttribute('data-key', 'YOUR_TRACKING_ID');
document.head.appendChild(s);
})();
</script>The install check reads the HTML of your homepage, so it cannot see scripts that Google Tag Manager adds. The status changes to Receiving data when the first visit arrives. See Tracking Scripts.
Common problems on Google Tag Manager
- The container is not published. A saved tag does nothing until you click Submit and Publish.
- The tag fires only on some pages. Use the All Pages trigger.
- The HTML form is in the tag. Replace it with the Google Tag Manager form.
- The container is not on every page. The Google Tag Manager container code must be on every page of the site.
- A consent setting holds the tag back. Then VitalSentinel counts only visitors who accept. See Tracking Scripts.
Magento
For Magento 2 and Adobe Commerce stores, add the snippet in the admin. The VitalSentinel setup panel uses this method.
Install on Magento in the admin
- In the Magento admin, go to Content > Design > Configuration.
- Click Edit on your store view.
- Under Other Settings, expand HTML Head.
- Paste the snippet in the Scripts and Style Sheets field.
- Save the configuration.
- Clear the Magento cache.
The Web Analytics script finds Magento on its own for ecommerce tracking.
Common problems on Magento
- The scripts do not run on checkout pages. Magento 2.4 applies a Content Security Policy. Ask your developer to add the VitalSentinel hosts to the store's CSP allowlist (
csp_whitelist.xml). See Tracking Scripts for the hosts. - The change does not show. Clear the Magento cache and any full-page cache or CDN.
- The snippet is only in one store view. Add it to each store view that you want to measure.
Next.js
Use the next/script component in the root layout, so that the scripts load on every route. Next.js passes data-* attributes on to the script tag.
Next.js App Router
In your root layout (app/layout.tsx):
import Script from 'next/script';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
strategy="afterInteractive"
/>
<Script
src="https://analytics.vitalsentinel.com/analytics.js"
data-key="YOUR_TRACKING_ID"
data-spa="true"
strategy="afterInteractive"
/>
</body>
</html>
);
}Next.js Pages Router
In pages/_app.js:
import Script from 'next/script';
export default function MyApp({ Component, pageProps }) {
return (
<>
<Script
src="https://rum.vitalsentinel.com/rum.js"
data-key="YOUR_TRACKING_ID"
strategy="afterInteractive"
/>
<Script
src="https://analytics.vitalsentinel.com/analytics.js"
data-key="YOUR_TRACKING_ID"
data-spa="true"
strategy="afterInteractive"
/>
<Component {...pageProps} />
</>
);
}Common problems on Next.js
- Web Analytics counts only the first page. A Next.js site changes pages in the browser. Set
data-spa="true", or select Enabled in Single page app (SPA) mode. The RUM script finds these page changes on its own. - You used
strategy="worker". This strategy moves the script into a web worker, away from the page. UseafterInteractive. - Your site sends a Content Security Policy. Add the VitalSentinel hosts to it. See Tracking Scripts.
- No data from preview deployments. Web Analytics accepts hits only from the host of your domain. The RUM script skips hosts such as
preview.example.com.
Nuxt
Nuxt 3
In nuxt.config.ts:
export default defineNuxtConfig({
app: {
head: {
script: [
{
src: 'https://rum.vitalsentinel.com/rum.js',
'data-key': 'YOUR_TRACKING_ID',
async: true
},
{
src: 'https://analytics.vitalsentinel.com/analytics.js',
'data-key': 'YOUR_TRACKING_ID',
'data-spa': 'true',
async: true
}
]
}
}
});Nuxt 2
In nuxt.config.js:
export default {
head: {
script: [
{
src: 'https://rum.vitalsentinel.com/rum.js',
'data-key': 'YOUR_TRACKING_ID',
async: true
},
{
src: 'https://analytics.vitalsentinel.com/analytics.js',
'data-key': 'YOUR_TRACKING_ID',
'data-spa': 'true',
async: true
}
]
}
};Common problems on Nuxt
- Web Analytics counts only the first page. Nuxt changes pages in the browser. Set
data-spa="true"on the Web Analytics script. - Your site sends a Content Security Policy. Add the VitalSentinel hosts to it. See Tracking Scripts.
Other sites (HTML)
For a static site, a site that you build by hand, or any framework that has one HTML template, paste the snippet into that template.
Install on an HTML site
- Open the HTML template or layout file that every page of your site uses.
- Paste the HTML snippet just before the closing
</head>tag. - Save the file.
- Upload or deploy the change to your live site.
- Clear the cache of your host or CDN, if you use one.
For a Create React App or Vue CLI project, the template is usually public/index.html. For a site without a shared template, paste the snippet on each page.
Common problems on HTML sites
- Some pages have no snippet. Every page needs the snippet. Pages without it send no data.
- A React, Vue or other single-page app counts only the first page. Set Single page app (SPA) mode to Enabled for Web Analytics.
- You open the page from your computer. The scripts do nothing on a page that opens from a file (
file://). Test on your live site.
Check the installation
After you install the scripts, go back to the app and click Check installation in the Is it working? card. See Tracking Scripts.
To check the scripts in your browser:
- Open your site.
- Open the developer tools of the browser (F12).
- Open the Network tab.
- Filter for
vitalsentinel. - Make sure that
rum.jsandanalytics.jsload fromrum.vitalsentinel.comandanalytics.vitalsentinel.com. - Make sure that you see requests to
app.vitalsentinel.com. These requests send the data.
Numbers appear in VitalSentinel within minutes of the first real visit.
Troubleshooting
Why do the scripts not load on my platform?
If an ad blocker runs in your browser, turn it off for the test. If your site has a Content Security Policy, allow the VitalSentinel hosts. If your platform caches pages, clear the cache after the change. If a plugin delays or combines JavaScript, exclude the two VitalSentinel scripts. For each cause, see Tracking Scripts.
Why do I see no data after I installed the scripts on my platform?
If you test on a staging, preview or local copy of your site, the scripts can skip the visit. If the site runs on another host than the domain, Web Analytics discards the hits. Make sure that the snippet is on every page, also the homepage. See Tracking Scripts for the install check results.
Related
- Tracking Scripts - where to find the snippet, the install check and troubleshooting
- RUM Script - all options of the RUM script
- Web Analytics Script - all options of the Web Analytics script
- Ecommerce - the shop reports
- RUM Monitoring - what the RUM data shows
- Web Analytics - what the Web Analytics data shows
Tracking scripts
Install the VitalSentinel RUM and Web Analytics tracking scripts with one tracking ID, choose a privacy mode, and check that the scripts work.
RUM script
Reference for the VitalSentinel RUM script - snippet, data attributes, consent mode, SPA support, JavaScript API, collected data and troubleshooting.