Installation Guide
This guide will walk you through the process of installing the Poliage JavaScript SDK on your website. The SDK allows you to easily integrate Poliage's powerful personalization and analytics features into your web application.
Environment ID
Before you begin, you'll need to obtain your unique Environment ID from the Poliage dashboard. This ID is used to identify your application and ensure that data is properly tracked and attributed.
To find your Environment ID:
- Log in to your Poliage account
- Navigate to the Settings page
- Click on the Environments tab
- Copy the Environment ID for the desired environment
If you haven't created an environment yet, you can do so by clicking the New Environment button and following the prompts.
Install with HTML
The simplest way to install the Poliage SDK is by adding a <script>
tag to your HTML file. Place the following code snippet just before the closing </body>
tag on each page where you want to use Poliage:
<script src="https://cdn.poliage.com/sdk/latest/poliage.min.js"></script>
<script>
window.poliage =
window.poliage ||
function () {
;(window.poliage.q = window.poliage.q || []).push(arguments)
}
poliage('init', 'YOUR_ENVIRONMENT_ID')
</script>
Replace 'YOUR_ENVIRONMENT_ID'
with the Environment ID you obtained in the previous step.
For performance reasons, we recommend adding this script as the last element in the <body>
tag.
Install with npm/yarn
If you're using a build tool like webpack or Rollup, you can install the Poliage SDK via npm or yarn. Run one of the following commands in your project directory:
npm install @poliage/web-sdk
or
yarn add @poliage/web-sdk
Then, import and initialize the SDK in your JavaScript code:
import poliage from '@poliage/web-sdk'
poliage('init', 'YOUR_ENVIRONMENT_ID')
Again, replace 'YOUR_ENVIRONMENT_ID'
with your actual Environment ID.
Verify Installation
To verify that the Poliage SDK has been installed correctly, open your web application in a browser and look for the poliage
object in the JavaScript console:
- Open your web application in Google Chrome or Firefox
- Right-click anywhere on the page and select Inspect (Chrome) or Inspect Element (Firefox)
- Navigate to the Console tab
- Type
window.poliage
and press Enter
If the SDK is installed correctly, you should see an object with various properties and methods, such as identify
, track
, and personalize
.
If you see an error message or undefined
, double-check that the SDK script
is properly added to your HTML file or imported in your JavaScript code.
Congratulations! You've successfully installed the Poliage JavaScript SDK. You're now ready to start personalizing content, tracking events, and analyzing user behavior on your website.
🚀 Next, learn how to configure the SDK to start collecting data and delivering personalized experiences to your users.