Setup & Integration

Install SDK via Package Installation

Install the OneLence SDK as a project dependency and initialize tracking within your application lifecycle.

Overview

If your product is a SaaS application or a custom web application using a modern JavaScript framework, you can activate OneLence base tracking by installing the SDK via your package manager.

This setup provides greater control over event instrumentation, identity linking, and future advanced tracking configuration.

Use this method when:

  • your site is built with frameworks such as React, Vue, Nuxt, Next.js, or similar
  • you manage a JavaScript build pipeline
  • you want structured tracking control within your application code
  • your engineering team maintains the product frontend

Step 1. Install the SDK package

Install the OneLence browser runtime package using npm, yarn or pnpm.

BASH
npm install @crelora/mark

This adds the OneLence tracking client to your project dependencies.

Step 2. Import the SDK

Import the browser runtime into your application entry point or bootstrap file.

JAVASCRIPT
import { Mark } from '@crelora/mark';

The SDK should be initialized once during application startup.

Typical initialization locations include:

  • main application entry file
  • root layout component
  • global tracking service
  • client bootstrap lifecycle

Step 3. Initialize base tracking

Initialize the SDK using the publishable tracking key issued in your OneLence workspace.

JAVASCRIPT
Mark.init({
  key: 'pk_your_publishable_key',
  require_consent: false,  // 'auto': stored consent | true: require consent | false: immediate tracking
  autocapture: { pageview: true },
  site_id: 'your_site_id',
  site_host: 'your-site-host'
});

Best practice: Run Mark.init() once, client-side, at the root of your application.

Use the values provided in your own onboarding setup page. Do Not copy example values from documentation.

In case you're logged in as an OneLence user, you can fetch real values and use the code directly for your integration.

For reliable conversion measurement and backend workflows, you may also send events from your server.

Typical use cases:

  • payment confirmation after webhook processing
  • subscription lifecycle updates
  • CRM pipeline stage changes
  • backend-validated conversions

Server tracking requires:

  • using the server ingestion API
  • attaching visitor or user identity context
  • consistent event naming between browser and backend

This hybrid architecture improves attribution accuracy and prevents lost conversions.

Refer to the Server Tracking configuration guidefor implementation details.

What happens after initialization

Once the SDK is initialized and your application is deployed, OneLence automatically begins capturing:

  • page view activity
  • visitor session signals
  • marketing attribution parameters (UTM values, click IDs, etc.)

These signals form the foundation of visitor journey analysis and growth intelligence.

Custom interactions such as sign-ups, button clicks, purchases, or backend conversion events require additional tracking configuration and can be implemented in later setup steps.

If your site is primarily content-driven or managed through a CMS or website builder, the script snippet setup described in the previous section may provide a faster activation path.