Headless Integrations

Intelligems currently has limited support for headless integrations, but we have successfully supported several sites, and have a React npm package on the roadmap. This article will walk you through current headless capabilities.


In this article:


Add Intelligems JavaScript to Site

Add your Intelligems JavaScript to the <head> of your site. This will load Intelligems when the page loads in your end users' browsers.

<head>
  ...
  <script src="https://cdn.intelligems.io/<your_customer_id>.js"></script>
  ...
</head>

Your individual script tag is located on the settings page in the Intelligems App. 

Screen Shot 2022-12-06 at 12.07.20 PM

Building the Cart

There are two required components to building the cart.

The first is adding the igId to the cart custom attributes. You can get the igId from our Javascript API and include it in a snippet like this:

const input = {
customAttributes: [
{key: "igId", value: igData?.user.igId}
]
}

checkout = await shopifyStorefront.checkout.updateAttributes(
checkoutId,
input
)
 The second is adding the Test Group ID to each line item. A sample snippet is like this:
const customLineItemAttributes = [
{key: "_igTestGroup", value: igData?.user.getTestGroup(igData?.user.getExperiments()[0]?.id)?.id}
]

 You can find more information about our Javascript API here.