Lytical Tracking Code Installation Guide
Add the Lytical tracking code to your website to start collecting visitor analytics. This guide covers installation for popular website platforms, content management systems, and tag managers.
Your Tracking Code
Copy this code snippet and paste it into your website's HTML, just before the closing </head> tag or at the end of the <body> tag:
<script async src="https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN"></script>
Note: Replace
YOUR_TRACKING_TOKENwith your unique tracking token found in your Lytical dashboard under Settings > Website.
Website & CMS Integrations
Google Tag Manager
- Log in to your Google Tag Manager account
- Select your container (or create a new one)
- Click Tags in the left sidebar, then click New
- Click Tag Configuration and select Custom HTML
- Paste the following code:
<script async src="https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN"></script> - Click Triggering and select All Pages
- Name your tag (e.g., "Lytical Analytics")
- Click Save
- Click Submit to publish your changes
WordPress
Option 1: Using a Plugin (Recommended)
- Install and activate a header/footer script plugin like Insert Headers and Footers or WPCode
- Go to Settings > Insert Headers and Footers (or the plugin's settings page)
- Paste the tracking code into the Header section
- Save your changes
Option 2: Edit Theme Files
- Go to Appearance > Theme Editor in your WordPress admin
- Select your theme's
header.phpfile - Paste the tracking code just before the closing
</head>tag - Click Update File
Warning: If you update your theme, you may lose these changes. Consider using a child theme or a plugin instead.
Shopify
- Log in to your Shopify admin panel
- Go to Online Store > Themes
- Click Actions > Edit Code on your active theme
- Under Layout, click
theme.liquid - Find the closing
</head>tag - Paste the tracking code just before
</head> - Click Save
Wix
- Log in to your Wix account and open your site editor
- Click Settings in the left menu
- Select Custom Code under Advanced
- Click + Add Custom Code
- Paste the tracking code
- Name it "Lytical Analytics"
- Select Head for placement
- Choose All pages for pages to add code
- Click Apply
Squarespace
- Log in to your Squarespace account
- Go to Settings > Advanced > Code Injection
- Paste the tracking code in the Header field
- Click Save
Webflow
- Log in to your Webflow dashboard
- Open your project and go to Project Settings
- Click the Custom Code tab
- Paste the tracking code in the Head Code section
- Click Save Changes
- Publish your site to apply the changes
HubSpot
- Log in to your HubSpot account
- Click the Settings gear icon
- Go to Website > Pages in the left sidebar
- Scroll down to Site Header HTML
- Paste the tracking code
- Click Save
For HubSpot CMS Pages Only:
- Navigate to Marketing > Website > Website Pages
- Click on the page you want to edit
- Go to Settings tab
- Scroll to Advanced Options > Additional code snippets
- Paste the tracking code in the Head HTML field
- Click Publish
Drupal
- Install and enable the Asset Injector module (or similar)
- Go to Configuration > Development > Asset Injector > JS Injector
- Click + Add JS Injector
- Paste the tracking code (without the
<script>tags) - Set Header as the position
- Save your configuration
Alternative: Edit Theme Template
- Locate your theme's
html.html.twigfile - Paste the tracking code before the closing
</head>tag - Clear Drupal's cache
Joomla
- Log in to your Joomla admin panel
- Go to Extensions > Templates > Templates
- Click on your active template
- Select
index.php - Paste the tracking code before the closing
</head>tag - Click Save
Ghost
- Log in to your Ghost admin panel
- Go to Settings > Code injection
- Paste the tracking code in the Site Header field
- Click Save
Weebly
- Log in to your Weebly account
- Go to Settings > SEO
- Scroll down to Header Code
- Paste the tracking code
- Click Save
- Publish your site
BigCommerce
- Log in to your BigCommerce admin panel
- Go to Storefront > Script Manager
- Click Create a Script
- Set the following options:
- Name: Lytical Analytics
- Location: Head
- Pages: All Pages
- Script type: Script
- Paste the tracking code
- Click Save
Magento / Adobe Commerce
- Log in to your Magento admin panel
- Go to Content > Design > Configuration
- Select your store view and click Edit
- Expand HTML Head
- Paste the tracking code in the Scripts and Style Sheets field
- Click Save Configuration
- Clear the cache: System > Cache Management > Flush Magento Cache
Gatsby / React
Add the tracking code to your gatsby-ssr.js file:
import React from "react";
export const onRenderBody = ({ setHeadComponents }) => {
setHeadComponents([
<script
key="lytical"
async
src="https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN"
/>,
]);
};
Next.js
Add the tracking code to your _document.js or _document.tsx file:
import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html>
<Head>
<script
async
src="https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
Nuxt.js
Add the tracking code to your nuxt.config.js:
export default {
head: {
script: [
{
src: 'https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN',
async: true,
},
],
},
};
Framer
Framer makes it easy to add custom code to your site through site-wide custom code injection.
Installation Steps:
1. Open your Framer project and click on the Settings icon (gear) in the top-right corner
2. Navigate to General → Custom Code
3. In the End of <head> tag section, paste the following code:
<script async src="https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN"></script>
4. Replace YOUR_TRACKING_TOKEN with your unique tracking token from your Lytical dashboard
5. Click Save and Publish your site
Alternative: Page-Specific Installation
If you only want to track specific pages:
1. Select the page you want to track in the left sidebar
2. Click the Page Settings icon (gear next to the page name)
3. Scroll down to Custom Code
4. Paste the tracking code in the End of <head> tag section
5. Publish your changes
Note: Framer's preview mode may not trigger analytics events. Make sure to test on your published site.
HTML Website (Static)
For any static HTML website, paste the tracking code directly into your HTML file(s):
<!DOCTYPE html>
<html>
<head>
<title>Your Website</title>
<!-- Other head elements -->
<!-- Lytical Tracking Code -->
<script async src="https://lytcdn.com/lyt.js?site=YOUR_TRACKING_TOKEN"></script>
</head>
<body>
<!-- Your content -->
</body>
</html>
Verifying Installation
After adding the tracking code:
- Visit your website in a browser
- Go to your Lytical dashboard
- Navigate to Settings > Website
- Click Verify Installation to confirm the code is working
- You should see data appearing in your dashboard within a few minutes
Troubleshooting
No data appearing?
- Ensure the tracking code is placed correctly (before
</head>) - Check that your tracking token is correct
- Verify there are no JavaScript errors in your browser console
- Clear your website's cache and CDN cache
- Wait a few minutes for data to process
Code not found during verification?
- Some caching plugins may delay the appearance of new scripts
- Ensure you've published/saved your changes
- Check if your site uses a CDN that needs to be purged
Need Help?
If you're having trouble installing the tracking code, contact our support team or visit our help center for additional guidance.