Skip to main content

How to Install the Knock2 Script on Your Website

Get up and running with Knock2 in minutes. This guide covers installation for every major website platform.

Written by Knocky
Updated this week

Finding Your Script

  1. Log into your Knock2 dashboard

  2. Click Settings > Script

  3. Click the Copy button to copy the script to your clipboard

Installing the Script

Paste the script in your website's </head>. The script should be on every page where you want to track visitors.

After installation, the status indicator will show "Active" in green.


Important Notes

  • We do not recommend installing via Google Tag Manager. We recommend the script be added directly to the <head> of your site.

  • The script loads asynchronously and won't slow down your page.

  • Once installed, visitors will start appearing in your dashboard within minutes.


Platform Guides

  • Webflow

  • Framer

  • WordPress

  • Squarespace

  • Shopify

  • Wix

  • HubSpot CMS

  • Next.js / React

  • Ghost

  • Carrd

  • Unbounce

  • Instapage

  • Leadpages

  • Kajabi

  • Go High Level (GHL)

  • ClickFunnels

  • Gatsby / Static HTML


Webflow

Webflow lets you add custom code at the site level (requires a paid site plan).

  1. Log into Webflow and open the project where you want to install the script

  2. Click the Webflow logo (top-left) and select Site Settings

  3. In the left sidebar, click Custom Code

  4. Paste the Knock2 script into the Head Code section

  5. Click Save Changes, then click Publish to push the changes live

The script will automatically load on every page of your Webflow site.


Framer

  1. Open your Framer project

  2. Click the gear icon (Site Settings) in the top-right

  3. Scroll to Custom Code and expand the Head section

  4. Paste the Knock2 script

  5. Click Save, then Publish

Framer applies head code globally, so the script will run on all pages.


WordPress

Choose the method that matches your setup.

Option A: Header Injection Plugin (Recommended)

This is the easiest method and doesn't require editing theme files.

  1. Install and activate a header injection plugin such as WPCode or Head, Footer and Post Injections

  2. In your WordPress dashboard, go to the plugin's settings (e.g., Code Snippets > Header & Footer for WPCode, or Settings > Header and Footer for Head, Footer and Post Injections)

  3. Find the Header or HEAD section and paste the Knock2 script

  4. Click Save Changes

Option B: Theme File Editor

If you're using Elementor, skip this method and use Option C below.

  1. In your WordPress dashboard, go to Appearance > Theme File Editor

  2. In the file list on the right, click header.php

  3. Scroll to just before the closing </head> tag and paste the Knock2 script. Do not overwrite any existing code.

  4. Click Update File

If your theme includes a Header Code Injection field in its settings, you can paste the script there instead of editing header.php directly.

Option C: Elementor

Elementor manages its own header templates, so the Theme File Editor method won't work.

  1. In your WordPress dashboard, navigate to Elementor > Theme Builder and open your Header template

  2. Click Edit with Elementor

  3. Drag an HTML widget into the header section

  4. Click the widget and paste the Knock2 script into the HTML code editor (make sure both the opening <script> and closing </script> tags are included)

  5. Click Save, then clear any active caching plugins

Troubleshooting (WordPress)

  • Confirm the script appears only once in your source code. Duplication can cause errors.

  • If you see a blank screen after saving, re-check the script for missing or extra characters.

  • If you're using WP Rocket or another caching/optimization plugin, make sure the Knock2 script is excluded from any "Delay JavaScript" or "Defer JavaScript" settings.


Squarespace

Squarespace offers several options for adding custom scripts. We recommend using Code Injection.

  1. Log into your Squarespace account

  2. From the Home Menu, go to Website > Pages

  3. Scroll down to Website Tools and click Code Injection (under Advanced)

  4. Paste the Knock2 script into the Header field. This ensures the script loads on every page of your site.

  5. Click Save

Code Injection is the recommended method. It applies the script site-wide without needing to edit individual page HTML.


Shopify

  1. From your Shopify admin, go to Online Store > Themes

  2. Click the three-dot menu (⋯) on your current theme and select Edit Code

  3. Under Layout, click theme.liquid

  4. Find the </head> tag and paste the Knock2 script just above it

  5. Click Save

This installs the script on every page of your store, including product pages and checkout (if your plan allows theme editing on checkout).


Wix

Wix requires a Premium plan to add custom code.

  1. In your Wix dashboard, go to Settings

  2. Under the Advanced section, click Custom Code

  3. Click + Add Custom Code in the top-right corner

  4. Paste the Knock2 script into the text box

  5. Give the snippet a name (e.g., "Knock2 Tracking Script") for easy reference

  6. Under Add Code to Pages, select All pages

  7. When prompted, set it to Load code on each new page (not once per session)

  8. Under Place Code in, select Head

  9. Click Apply

Setting the script to load on each new page (rather than once per session) is important. Loading it only once will limit Knock2's ability to track visitors across pages.


HubSpot CMS

  1. In your HubSpot account, click the Settings icon in the top navigation bar

  2. In the left sidebar, go to Content > Pages

  3. Click the Choose a domain to edit dropdown and select your domain (or select Default settings for all domains to apply it everywhere)

  4. In the Site Header HTML section, paste the Knock2 script

  5. Click Save

This applies the script to every page on the selected domain.


Next.js / React

For React-based frameworks, add the script to your root layout or document.

Next.js (App Router)

In your app/layout.tsx (or .js):

export default function RootLayout({ children }) {   return (     <html lang="en">       <head>         {/* Paste Knock2 script here */}       </head>       <body>{children}</body>     </html>   ); }

Next.js (Pages Router)

Create or edit pages/_document.tsx:

import { Html, Head, Main, NextScript } from 'next/document';  export default function Document() {   return (     <Html>       <Head>         {/* Paste Knock2 script here using dangerouslySetInnerHTML */}         <script           dangerouslySetInnerHTML={{             __html: `// Paste the contents of your Knock2 script here`,           }}         />       </Head>       <body>         <Main />         <NextScript />       </body>     </Html>   ); }

Create React App / Vite

Paste the Knock2 script directly into the <head> section of your public/index.html file.


Ghost

  1. In your Ghost admin, go to Settings > Code Injection

  2. Paste the Knock2 script into the Site Header field

  3. Click Save

Ghost applies header code injection to every page on your site.


Carrd

  1. Open your Carrd site in the editor

  2. Click the gear icon (Site Settings) in the top-left

  3. Go to the Head section under Settings

  4. Paste the Knock2 script

  5. Save and Publish

Carrd requires a Pro plan to add custom code.


Unbounce

  1. Open your landing page in the Unbounce builder

  2. Click JavaScripts in the bottom-left panel

  3. Click Add New JavaScript

  4. Set placement to Head

  5. Paste the Knock2 script

  6. Click Save and Republish

Unbounce adds scripts per landing page, so you'll need to add it to each page you want to track. Use Global Scripts if available on your plan to apply it across all pages.


Instapage

  1. Open your page in the Instapage editor

  2. Click Settings (gear icon)

  3. Go to HTML/CSS > Head

  4. Paste the Knock2 script

  5. Click Save and Publish

Like Unbounce, Instapage is page-level. Add the script to each landing page you want to track.


Leadpages

  1. Open your page in the Leadpages editor

  2. Click Page Settings (gear icon in the left sidebar)

  3. Go to SEO & Analytics > Head Section Tracking Code

  4. Paste the Knock2 script

  5. Click Save and Publish


Kajabi

  1. Go to Settings > Site Details

  2. Scroll down to Header Tracking Code

  3. Paste the Knock2 script

  4. Click Save

This applies the script to your entire Kajabi site, including course pages and landing pages.


Go High Level (GHL)

  1. Go to Sites > Settings > Global Settings

  2. Find the Tracking Code (Head) section

  3. Paste the Knock2 script

  4. Click Save

For a specific funnel page:

  1. Open the funnel in the editor

  2. Click Settings on the page

  3. Paste the script in the Header Code field

  4. Click Save


ClickFunnels

ClickFunnels 2.0

  1. Go to Site Settings > Tracking Codes

  2. Paste the Knock2 script in the Head Tracking Code field

  3. Click Save

ClickFunnels Classic

  1. Open your funnel and click Settings on the page

  2. Go to the Tracking Code tab

  3. Paste the script in the Header Code section

  4. Click Save

ClickFunnels Classic requires adding the script to each funnel page individually.


Gatsby / Static HTML

For static sites built with Gatsby, Hugo, Jekyll, or plain HTML, add the Knock2 script directly to the <head> of your HTML.

Gatsby

Edit gatsby-ssr.js (create it if it doesn't exist):

export const onRenderBody = ({ setHeadComponents }) => {   setHeadComponents([     <script       key="knock2"       dangerouslySetInnerHTML={{         __html: `// Paste the contents of your Knock2 script here`,       }}     />,   ]); };

Plain HTML

Open every HTML file and paste the Knock2 script inside the <head> tag:

<html>   <head>     <!-- Your existing tags -->     <!-- Paste Knock2 script here -->   </head>   <body>     ...   </body> </html>

Troubleshooting

Script status still shows "Inactive"?

  • Make sure you published or saved your changes. Many platforms require a separate publish step.

  • Open your site in a browser, right-click, and select View Page Source. Search for "knock2" to confirm the script is in the <head>.

  • Clear your site's cache if you're using a CDN or caching plugin (common with WordPress).

Script installed but no visitors appearing?

  • Give it a few minutes. Visitors begin appearing in your dashboard shortly after the first page loads with the script active.

  • Confirm the script is loading by opening your browser's Developer Tools > Network tab and filtering for "knock2."

Using a custom domain with a proxy or CDN?

  • The script works behind Cloudflare, Vercel, Netlify, and other proxies. No special configuration is needed.

Need help? Contact us at support@knock2.ai or via the chat widget in your dashboard.

Did this answer your question?