Tracking your first site
Learn how to start tracking your first site.
Let’s get started by adding LWS Analytics to your website.
First, you’ll need an account. You can create a new account here or login if you already have one.
1. Create your first site
Section titled “1. Create your first site”Creating a site requires the following information:
- Site name: The name of your site, can be anything you want really.
- Domain: The domain of the site you want to track (additional domains can be added later).
- Reporting timezone: This is the timezone that determines what ‘today’ means. We handle UTC on our server, but you would want to see reports in your local timezone.
2. Install the SDK
Section titled “2. Install the SDK”The recommended way to add LWS Analytics is via our npm package. No external script tag required - just install the package and start tracking.
npm install @lws-analytics/scriptThen initialize it once in your app’s entry point:
// app/layout.tsx or index.tsximport { init } from '@lws-analytics/script';
// Initialize once at app startupinit({ siteId: 'your-site-id' });
export default function App({ children }) { return <>{children}</>;}'use client';
import { useEffect } from 'react';import { init } from '@lws-analytics/script';
export function AnalyticsProvider({ children }: { children: React.ReactNode }) { useEffect(() => { init({ siteId: 'your-site-id' }); }, []);
return <>{children}</>;}
// app/layout.tsximport { AnalyticsProvider } from './providers';
export default function RootLayout({ children }) { return ( <html> <body> <AnalyticsProvider>{children}</AnalyticsProvider> </body> </html> );}import { createApp } from 'vue';import { init } from '@lws-analytics/script';import App from './App.vue';
init({ siteId: 'your-site-id' });
createApp(App).mount('#app');If you prefer not to use npm, you can add the script directly to your HTML. Add this to your site’s <head> tag:
<script> window.LWS_ANALYTICS_SITE_ID = 'your-site-id';</script><script src="https://cdn.jsdelivr.net/npm/@lws-analytics/script/dist/script.js"></script>Replace your-site-id with the site ID from your dashboard.
That’s it ✨ it can really be this simple.
3. Getting your first page view
Section titled “3. Getting your first page view”To test if everything is working, visit the site you are tracking and refresh the dashboard. You should see that at least one unique visitor has visited your site.
Continue to the next article to learn how to track custom events.