Integration Guide
Vanilla JavaScript Integration
Section titled “Vanilla JavaScript Integration”Embed the Product Genie widget using a simple HTML snippet and our provided embed script.
Steps:
-
Obtain Keys: Get your unique
Public Key
from your Product Genie dashboard. -
Add Container Div: Place the following
div
element in your HTML where you want the widget to appear. Replace the placeholder values with your actualPublic Key
and theProduct ID
for the specific product page.<divid="productgenie-widget"data-public-key="YOUR_PUBLIC_KEY"data-product-id="YOUR_PRODUCT_ID"></div>- Replace
YOUR_PUBLIC_KEY
with the key obtained in step 1. - Replace
YOUR_PRODUCT_ID
with the specific ID for this product (this could be a SKU, database ID, etc., consistent with how you identify products in Product Genie).
- Replace
-
Include Embed Script: Add the following script tag to your HTML page, preferably just before the closing
</body>
tag.<script src="https://widget.productgenie.io/embed.js" async defer></script>- Make sure the
src
attribute points to the location where theembed.js
file is hosted. The URLhttps://widget.productgenie.io/embed.js
is the default location. - The
async
anddefer
attributes ensure the script loads without blocking your page rendering.
- Make sure the
How it works:
The embed.js
script will automatically:
- Find the
<div id="productgenie-widget">
. - Read the
data-public-key
anddata-product-id
attributes. - Determine the current page URL (
website_url
). - Create an
iframe
pointing to the Product Genie widget application, passing the necessary configuration as URL parameters. - Insert the
iframe
into the container div. - Listen for messages from the iframe to automatically adjust its height, ensuring seamless integration without internal scrollbars.
With these steps, the Product Genie widget should load and function correctly on your page.