Installation Guide
Add BadgerFy.ai to your website in minutes. Choose your platform below for step-by-step instructions. You'll find your Project ID in the BadgerFy.ai dashboard under your project settings.
YOUR_PROJECT_ID in all examples with your actual Project ID from the BadgerFy.ai dashboard.Static Website / Manual Installation
For static HTML websites, simply add our script tag to your pages. This works with any HTML-based website including custom builds, WordPress, and other CMS platforms.
Basic Installation
Add this script tag just before the closing </body> tag on every page where you want BadgerFy.ai to appear:
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
Full HTML Example
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>My Website</title></head><body><!-- Your website content --><h1>Welcome to my store</h1><!-- BadgerFy.ai Script - Add before </body> --><scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script></body></html>
Next.js Installation
For Next.js applications, use the built-in Script component for optimal loading performance. This approach ensures the script loads after the page becomes interactive, improving your Core Web Vitals.
Create a BadgerFy Component
Create a new component file (e.g., components/BadgerfyEmbed.js):
import Script from 'next/script';export default function BadgerfyEmbed() {return (<Scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"strategy="afterInteractive"/>);}
Add to Your Layout
Import and add the component to your root layout or any page layout:
import BadgerfyEmbed from '../components/BadgerfyEmbed';export default function Layout({ children }) {return (<><header>{/* Your header */}</header><main>{children}</main><footer>{/* Your footer */}</footer>{/* BadgerFy.ai Embed */}<BadgerfyEmbed /></>);}
strategy="afterInteractive" ensures the script loads after the page becomes interactive, which is recommended for third-party scripts.Shopify Installation
Add BadgerFy.ai to your Shopify store through the theme editor.
Installation Steps
- Log in to your Shopify admin panel
- Go to Online Store â Themes
- Click Actions â Edit code on your current theme
- In the Layout folder, click on theme.liquid
- Find the closing
</body>tag - Paste the following code just before it:
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
- Click Save
- Visit your storefront to verify the agent appears
BigCommerce Installation
Add BadgerFy.ai to your BigCommerce store using Script Manager or direct file editing.
Option A: Using Script Manager (Recommended)
- Go to Storefront â Script Manager
- Click Create a Script
- Fill in the details:
- Name: BadgerFy.ai
- Location: Footer
- Pages: All Pages (or select specific pages)
- Script type: Script
- Paste the script code:
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
- Save your changes
Option B: Edit Theme Files
- Go to Storefront â Themes â Advanced â Edit Theme Files
- Navigate to templates/layout/base.html
- Add the script before the closing
</body>tag - Save the file
Adobe Commerce / Magento Installation
Add BadgerFy.ai to Adobe Commerce (Magento) through the admin panel or theme files.
Option A: Using Admin Panel (Recommended)
- Log in to your Magento Admin Panel
- Navigate to Content â Design â Configuration
- Select your store view and click Edit
- Expand the Footer section
- In the Miscellaneous Scripts field, paste:
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
- Save the configuration
- Clear the cache: System â Cache Management â Flush Magento Cache
Option B: Edit Theme Template
For more control, add the script to your theme's template file:
- Navigate to your theme folder:
app/design/frontend/[Vendor]/[Theme]/ - Create or edit
Magento_Theme/templates/html/scripts.phtml - Add the script code
- Update your layout XML to include the template before
</body> - Clear cache and deploy static content
bin/magento cache:flush from the command line.WooCommerce Installation
Add BadgerFy.ai to your WooCommerce store through your WordPress theme or using a plugin.
Option A: Edit Theme (Recommended)
- Log in to your WordPress admin panel
- Go to Appearance â Theme File Editor
- Select your active theme and find footer.php
- Add the following code just before the closing
</body>tag (or before<?php wp_footer(); ?>):
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
- Click Update File
Option B: Using functions.php
For a more robust solution that survives theme updates, add the script via your theme's functions.php:
// Add BadgerFy.ai script to footerfunction add_badgerfy_script() {?><scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script><?php}add_action('wp_footer', 'add_badgerfy_script');
Option C: Using a Plugin
If you prefer not to edit theme files, you can use a plugin like Insert Headers and Footers or WPCode:
- Install and activate a code snippet plugin (e.g., WPCode)
- Create a new snippet and set it to run in the Footer
- Paste the BadgerFy.ai script code
- Save and activate the snippet
Wix Installation
Add BadgerFy.ai to your Wix website using the Custom Code feature in site settings.
Installation Steps
- Log in to your Wix account and open your site editor
- Click Settings in the left sidebar
- Select Custom Code under Advanced Settings
- Click + Add Custom Code
- Paste the following code:
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
- Configure the code placement:
- Name: BadgerFy.ai
- Add Code to Pages: All pages (or select specific pages)
- Place Code in: Body - end
- Click Apply
- Publish your site to see the changes
Squarespace Installation
Add BadgerFy.ai to your Squarespace site using Code Injection in your site settings.
Installation Steps
- Log in to your Squarespace account
- Go to Settings â Advanced â Code Injection
- In the Footer section, paste the following code:
<scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
- Click Save
- Visit your live site to verify the installation
Page-Specific Installation
To add BadgerFy.ai to specific pages only:
- Edit the page where you want BadgerFy.ai to appear
- Click the gear icon to open Page Settings
- Go to the Advanced tab
- Paste the script in the Page Header Code Injection field (it will still load in the correct position)
- Save the page settings
Verifying Your Installation
After installing the script, verify it's working correctly:
- Visit your website in a browser
- Open the browser's Developer Tools (F12 or right-click â Inspect)
- Go to the Network tab and filter by "badgerfy"
- Refresh the page and confirm the script loads successfully
- If you have an enabled agent configured for that page, it should appear
data-test-mode="true" to your script tag. This enables test mode which loads disabled agents and provides detailed console logging.- Test mode only works on
localhostâ it will not function on production or staging servers. - Performance may be slower due to uncached data lookups.
- AI generations in test mode will consume tokens from your plan allocation.
Lifecycle Callbacks
BadgerFy.ai provides optional lifecycle callbacks that you can use to integrate with your application's logic. Define these in your configuration before the script loads.
onLoad Callback
The onLoad callback fires when BadgerFy.ai has fully loaded and initialized. Use this to trigger actions that depend on BadgerFy.ai being ready.
<script>window.badgerfyaiConfig = {onLoad: () => {console.log('BadgerFy.ai is ready!');// Access the BadgerFy.ai APIconst agents = window.badgerfyai.getAgents();console.log('Active agents:', agents);}};</script><!-- BadgerFy.ai Script - Load AFTER config --><scriptsrc="https://app.badgerfy.ai/embeds/badgerfy.min.js"data-project-id="YOUR_PROJECT_ID"async></script>
onEngagement Callback
The onEngagement callback fires whenever a user engagement is recorded. This allows you to react to engagements in real-time, such as sending data to your analytics platform or triggering custom logic.
window.badgerfyaiConfig = {onEngagement: ({ agentId, agentType, engagementAction, pagePath }) => {console.log('User engaged!', { agentId, agentType, engagementAction });// Example: Send to Google Analytics 4gtag('event', 'badgerfy_engagement', {agent_id: agentId,agent_type: agentType,engagement_action: engagementAction,page_path: pagePath});}};
The onEngagement callback receives an object with the following properties:
agentId- The unique identifier of the agentagentType- The type of agent (assistant, quiz, nudge, recommendation-strip)engagementAction- The action that triggered the engagement (e.g., chat-engagement, quiz-completed, nudge-cta-click, product-clicked)pagePath- The page path where the engagement occurred