Skip to main content
When you call new TappdSDK(config), you pass a configuration object that controls how the SDK behaves — from session timeouts and page-view tracking to in-app message delivery and debug logging. Only appId is required; every other option has a sensible default you can override as needed.

Full configuration example

The snippet below shows every available option with its default value. Copy it as a starting point and remove any options you don’t need to change.

Configuration reference

string
required
Your unique App ID from the Tappd dashboard. This identifies your application and is required for every SDK operation. Find it under Settings → Apps in your Tappd Dashboard.
string
default:"https://sdk.gotappd.com/api/v1/sdk"
The API endpoint the SDK sends data to. You only need to change this if you’re using a self-hosted Tappd instance or a custom domain.
boolean
default:"true"
Automatically records page views on the initial load and on every client-side navigation. This includes History API changes (push/pop state), which means single-page applications built with React Router, Vue Router, and similar libraries are tracked without any extra setup.Set this to false only if you want to call tappd.trackPageView() manually on every route change.
number
default:"30"
The number of minutes of user inactivity that triggers a new session. After the timeout elapses, the next user action starts a fresh session. Adjust this to match how your users typically interact with your application — a content site might use a longer timeout, while a transactional app might use a shorter one.
boolean
default:"false"
When enabled, the SDK automatically listens for link clicks (<a> tags) and form submissions and records them as events — no manual track() calls needed. Link clicks fire a link_click event; form submissions fire a form_submit event, both with relevant metadata attached.Leave this disabled if you prefer to track interactions explicitly, which gives you more control over the event names and properties you capture.
boolean
default:"true"
Enables the in-app messaging system, which lets you fetch and display banners, popups, and modals created in the Tappd dashboard. Set this to false to disable all in-app message functionality globally, regardless of other message-related settings.
boolean
default:"true"
When true, the SDK automatically fetches pending in-app messages from the API and displays any that match the current user’s targeting rules. Requires enableInAppMessages to also be true.Set this to false if you want to control when messages appear — for example, only showing them on certain pages or after specific events.
number
default:"30"
How often, in seconds, the SDK checks for new in-app messages. Only applies when autoDisplayMessages is true. Lower values mean users see new messages sooner; higher values reduce API requests.
string
The id of a DOM element to render in-app messages into. If you don’t set this, messages are appended directly to <body>. Use a custom container to control exactly where messages appear in your layout — for example, inside a fixed header or notification area.
boolean
default:"false"
Enables verbose logging to the browser console. When true, the SDK logs every operation — initialization, session events, tracked events, identified users, and message fetches — prefixed with [Tappd SDK].Always set this to false in production to keep your console output clean.

Environment-based configuration

Development vs. production

Keep your development and production configurations separate using environment variables and a NODE_ENV check. This pattern enables debug logging locally without any risk of enabling it in production.

Multiple environments

If you maintain separate Tappd apps for development, staging, and production, use an environment-keyed config object to switch between them automatically.

Common environment variable names

Never commit App IDs or API keys directly in your source code. Always read them from environment variables, and make sure your .env files containing real credentials are in .gitignore.

Best practices

Follow these guidelines to get the most reliable and maintainable SDK integration:
  • Use environment variables for your App ID in production. This prevents accidental exposure of credentials in source control and makes rotating IDs straightforward.
  • Enable debug only in development. Debug logging writes detailed output to the console, which is useful during integration but noisy in production.
  • Leave autoTrack enabled for most applications. It gives you page-view data immediately with zero extra code, including in SPAs that use client-side routing.
  • Set sessionTimeout based on how your users actually behave. A short timeout (15–20 min) suits transactional or task-focused apps; a longer timeout (45–60 min) suits content or research-heavy apps.
  • Keep enableAutoCapture disabled unless you need it. Manual tracking calls give you precise control over event names and properties, which keeps your analytics data clean and meaningful.

Next steps

API Reference

Explore every method available on the TappdSDK instance.

In-App Messages

Learn how to configure and display in-app messages.

Examples

See configuration options applied in real-world scenarios.