Nucleus logo

Web Integration

Installation

1. Go to https://nucleusanalytics.io/ and log in
2. Click on the website icon to create a new property
3. Insert the name of the property and click Save
4. Copy the following snippet:

<script 
    type="module" 
    id="nucleus-script" 
    src="https://cdn.nucleusanalytics.io/widgets/latest/widget.js" 
    data-npuk="<PUBLIC_KEY>" 
    data-nat="web">
</script>

For modern browsers you can place the script tag just before the closing body tag. For old browsers you must place the script tag in the head

5. After the integration is complete you can verify the status inside the Nucleus Analytics dashboard. When a property is created, the status remains inactive until a visit has been registered. After a visit has been registered, the status becomes active

6. Now you have access to the engagement metrics in the window object. To access it, paste the following into your code:

window.nucleus?.engagement

7. If you want to get a specific engagement value, you can "dot" into the desired value as shown below:

window.nucleus?.engagement?.engagement_score

8. The engagement values can now be injected into the bid request. The engagement values are retrieved asynchronously and you can choose to attach an EventListener to the engagement event to be sure the values are available when you need them

window.addEventListener('nucleus-engagement', ({ detail: engagement }) => console.log('Engagement values', engagement))