Basic Configuration
Once you've installed the Poliage JavaScript SDK, the next step is to configure it to start collecting data and personalizing content for your users. This guide will walk you through the basic configuration options and best practices.
Identify Users
To deliver personalized experiences, Poliage needs to know who your users are. You can identify users by calling the identify
method with a unique user ID and optional traits:
poliage('identify', 'user_id_123', {
email: 'john@example.com',
name: 'John Doe',
plan: 'premium',
})
The user ID should be a stable identifier that uniquely represents a user, such as a database ID or email address hash. Avoid using personally identifiable information (PII) as the user ID.
Track Events
Events are actions that users take in your application, such as clicking a button, viewing a page, or making a purchase. You can track events using the track
method:
poliage('track', 'Button Clicked', {
button_id: 'cta_button',
text: 'Sign Up Now',
})
The first argument is the event name, and the second argument is an optional object containing event properties.
Choose clear, descriptive event names that reflect the user's action. Avoid generic names like "click" or "view".
Track Attributes
In addition to events, you can also track user attributes using the setAttributes
method:
poliage('setAttributes', {
subscription_plan: 'pro',
signup_date: '2023-03-01',
})
Attributes are key-value pairs that describe characteristics of a user, such as their plan type, signup date, or preferences.
Test / Deploy
Before deploying your Poliage integration to production, it's important to test it thoroughly in a staging or development environment. You can use the Poliage debugger tool to inspect the data being sent and ensure that everything is working as expected.
To enable the debugger, call the debug
method:
poliage('debug', true)
This will log all Poliage API calls to the JavaScript console, allowing you to inspect the data being sent and troubleshoot any issues.
Disable the debugger in production by calling poliage('debug', false)
or
removing the debug
call entirely.
Customize Appearance
Poliage provides a range of options for customizing the appearance of personalized content and UI elements, such as recommendation widgets and pop-ups. You can configure these options in the Poliage dashboard or programmatically using the setOptions
method:
poliage('setOptions', {
theme: 'dark',
accentColor: '#ff5722',
fontFamily: 'Roboto, sans-serif',
})
See the Customization Guide for a full list of available options.
Anonymous Visitors / Identified Visitors
Poliage tracks data for both anonymous visitors and identified users. When a visitor first arrives on your site, they are assigned an anonymous ID that is stored in a cookie. This allows Poliage to track their behavior and deliver personalized content even before they've created an account or logged in.
Once a visitor is identified using the identify
method, their anonymous ID is merged with their user ID, and all future events and attributes will be associated with that user.
To ensure data accuracy and privacy compliance, be sure to call identify
as
soon as a user is authenticated, typically after login or signup.
With these basic configuration steps complete, you're ready to start delivering personalized experiences to your users! Check out our guides on tracking events, user segmentation, and personalization to learn more.