Submit Article Requests

Do you have a suggestion for an article you would like to see created?
Feel free to submit this form and add your suggestions to our document board.

Please fill out the contact form below and we will reply as soon as possible.

  • Integration Hub
  • Contact Us
  • Docs home
  • Installation & Developers
  • Installing Appcues on Web

Install the Appcues SDK

Add the Appcues SDK to your web application so you can show experiences to your users.

Updated at November 25th, 2026

Submit Article Requests

Do you have a suggestion for an article you would like to see created?
Feel free to submit this form and add your suggestions to our document board.

Please fill out the contact form with the details about the help content you'd like to see.

  • Home

  • Getting Started

    • Installation & Developers

      • Campaigns

        • Web Experiences

          • Mobile Experiences

            • Analytics & Data

              • Workflows

                • Integrations

                  • Account Settings

                    Table of Contents

                    Web installation steps Prerequisite Choose your installation method Install via script snippet (recommended) Track page changes TypeScript Single-page applications Load the script asynchronously (window.Appcues queue pattern) Install via NPM Track page changes Optional settings How setup handles early method calls TypeScript support (NPM) Run JavaScript snippets with NPM Option 1: Load snippets from Appcues Option 2: Bundle snippets in your app Confirm it worked If the SDK isn't loading Still stuck? Related

                    Web installation steps

                    You're on step 1 of 3.

                    Step Article
                    1. Install the SDK You are here
                    2. Identify users and groups Identify users and groups
                    3. Track events Track events in your web app

                    Before you start, decide which properties and events to send: Choose which events and properties to send.

                    Prerequisite

                    • Access to your team's Appcues account (you'll need your Appcues Account ID)
                    • Access to your application's codebase
                    • A completed installation plan (recommended)
                    • A read of Install Appcues without rework before you start (recommended)
                    • A decision on which elements Appcues will target. See Prepare your frontend for element targeting.

                    This guide covers direct installation on web. For other methods, see: Segment | Google Tag Manager | Rudderstack |  Freshpaint | Mobile SDK 

                    Choose your installation method

                    You can install the SDK via a script snippet or an NPM package. The script snippet is recommended for most teams.

                    Method Best for Updates TypeScript JavaScript snippets
                    Script snippet Most teams Automatic — always runs the latest SDK Manual declaration required Load automatically
                    NPM package Teams that need version control Manual — you update the package version Full built-in support Off until you choose how to load them. See Run JavaScript snippets with NPM.

                    Install via script snippet (recommended)

                    Add the following code inside the <head> tag of your page(s). Replace YOUR_APPCUES_ID with the Account ID shown at the top of Settings > Apps & Installation > Web.

                    <script type="text/javascript">
                      window.AppcuesSettings = { enableURLDetection: true };
                    </script>
                    <script src="//fast.appcues.com/YOUR_APPCUES_ID.js"></script>

                    For a copyable version of this snippet, click View installation guide on Settings > Apps & Installation > Web.

                    Add the script on every page where you want Appcues to run. You can do this by placing it in your index.html or another root file. If you want more control, add it only to specific pages.

                    Track page changes

                    The enableURLDetection setting tells the SDK to monitor URL changes automatically. Every time the URL changes, the SDK notifies Appcues so it can check whether the user qualifies for any experiences targeted to that page. This powers URL-based page targeting and cross-page experiences — without it, Appcues won't know when users navigate within your app.

                    You don't need to call Appcues.page() manually with this setting enabled. The Appcues.identify() call (see Identify Users and Groups) also triggers a page check, so page tracking begins as soon as the user is identified.

                    TypeScript

                    If you're using TypeScript and see a 'does not exist' error related to Appcues, declare it as a global variable:

                    declare global {
                      interface Window { Appcues: any; }
                    }
                    declare global {
                      interface Window { AppcuesSettings: any; }
                    }

                    Single-page applications

                    If you're using React, Next.js, Vue, Angular, or another SPA framework, enableURLDetection handles page changes automatically. If you see Flows restarting or disappearing during navigation, see the SPA guide for troubleshooting and manual page tracking options.

                    Load the script asynchronously (window.Appcues queue pattern)

                    By default, the Appcues script loads synchronously — it blocks other scripts until it finishes. If page load performance is a concern, you can load it asynchronously so it downloads in parallel with the rest of your page.

                    Add this setup code before the Appcues script. It creates a queue that buffers any Appcues method calls until the SDK finishes loading:

                    <script>
                      (function() {
                        if (!window.AppcuesReady) {
                          window.AppcuesReady = function(callback) {
                            callback && window.AppcuesReady.q.push(callback);
                            if (window.Appcues) {
                              while (window.AppcuesReady.q.length) {
                                cb = window.AppcuesReady.q.shift();
                                if (typeof cb === 'function') cb();
                              }
                            }
                          };
                          window.AppcuesReady.q = [];
                        }
                      })();
                    </script>
                    

                    Then load the Appcues script with async and call AppcuesReady() on load:

                    <script src="//fast.appcues.com/YOUR_APPCUES_ID.js" async onload="AppcuesReady()"></script>
                    

                    To call Appcues methods safely before the SDK has loaded, wrap them in AppcuesReady():

                    AppcuesReady(function() {
                      Appcues.identify("USER_ID", { email: "user@example.com" });
                    });
                    

                    This ensures identify() runs as soon as the SDK is ready, regardless of load order. You can call AppcuesReady() multiple times — all callbacks are queued and executed in order.

                    If you use the NPM package instead, async loading is handled automatically by await Appcues.setup() and you don't need this pattern.

                    Install via NPM

                    Install the package:

                    npm install @appcues/web-sdk --save

                    The Appcues SDK is also available as a public NPM package at https://www.npmjs.com/package/@appcues/web-sdk

                    Initialize the SDK when your application launches. Replace APPCUES_ACCOUNT_ID with the Account ID shown at the top of Settings > Apps & Installation > Web:

                    import Appcues from '@appcues/web-sdk'
                    
                    window.AppcuesSettings = { enableURLDetection: true };
                    await Appcues.setup('APPCUES_ACCOUNT_ID')

                    Track page changes

                    enableURLDetection tells the SDK to monitor URL changes automatically. It powers URL-based page targeting and cross-page experiences — without it, Appcues won't know when users navigate within your app.

                    enableURLDetection is a window.AppcuesSettings global, not an option passed to setup(). Set it before Appcues.setup() runs.

                    If you prefer full control over when page checks happen — or your app uses non-standard routing — you can skip enableURLDetection and call Appcues.page() manually on each route change instead. See the SPA guide for details.

                    Optional settings

                    Appcues.setup accepts an optional settings object as the second argument:

                    Setting Type When to use
                    apiHostName string When proxying the Appcues API through a custom domain. See self-hosting the bootstrap script.
                    bundleDomain string Set to https://fast.eu.appcues.com for EU accounts that are not using a custom proxy domain.
                    enableRemoteSnippetLoading boolean Set to true to run your account's JavaScript snippets. Defaults to false. Requires version 7.36.0 or later. See Run JavaScript snippets with NPM.

                    Example:

                    import Appcues from '@appcues/web-sdk'
                    
                    window.AppcuesSettings = { enableURLDetection: true };
                    await Appcues.setup('APPCUES_ACCOUNT_ID', {
                      apiHostName: 'you.customdomain.com'
                    })

                    After setup completes, you can import the SDK into any module and use its public methods immediately.

                    How setup handles early method calls

                    Appcues.setup runs asynchronously. If you call any Appcues method before setup finishes, the SDK buffers those calls in memory and replays them in order once setup completes. No data is lost.

                    TypeScript support (NPM)

                    The NPM package includes full type definitions for all SDK methods and properties. You get autocompletion, type checking, and error detection in your editor without any additional setup.

                    Run JavaScript snippets with NPM

                    If your team uses JavaScript snippets, the NPM package doesn't run them until you choose how they reach your app. Until then, JavaScript blocks don't render and click actions that run a snippet do nothing. The script snippet install loads them automatically.

                    Snippets are off by default on NPM because they run code on your page that isn't part of your own build. Pick one of two options:

                      Option 1: Load from Appcues Option 2: Bundle in your app
                    How snippets reach your app The SDK downloads them from Appcues when the page loads You download them and ship them in your build
                    After someone publishes a snippet change Live on the next page load Nothing changes until you download the file again and deploy
                    Code review None. The browser checks the file against a hash, but that hash also comes from Appcues Snippet changes go through your normal review and release
                    Setup One option on setup() A downloaded file and one import
                    Best for Teams who want snippets to update like the rest of their Appcues content Teams that require all JavaScript to be reviewed and bundled

                    Option 1: Load snippets from Appcues

                    1. Update the package to version 7.36.0 or later.
                    npm install @appcues/web-sdk@latest --save
                    1. Pass enableRemoteSnippetLoading: true to Appcues.setup().
                    import Appcues from '@appcues/web-sdk'
                    
                    window.AppcuesSettings = { enableURLDetection: true };
                    await Appcues.setup('APPCUES_ACCOUNT_ID', {
                      enableRemoteSnippetLoading: true
                    })

                    When your account has published snippets, the SDK adds a script tag for https://<your API host>/v1/accounts/<account ID>/snippets.js with an integrity hash. The browser refuses to run the file if its contents don't match the hash. If the file can't load, experiences still show without your snippets, and the console logs [Appcues] Failed to load snippet bundle.

                    If your app sends a Content Security Policy, script-src must allow your API host: https://api.appcues.net unless you set apiHostName. Snippets that load external dependencies need those hosts too. See Configure Content Security Policies.

                    Option 2: Bundle snippets in your app

                    Leave enableRemoteSnippetLoading off and ship a copy of your snippet file in your own build.

                    1. Download your account's snippet file. The first line reads your API host from your account settings. EU accounts read settings from fast.eu.appcues.com instead of fast.appcues.com.
                    API_HOST=$(curl -fs https://fast.appcues.com/bundle/accounts/APPCUES_ACCOUNT_ID/settings | jq -r .api_hostname)
                    curl -fsSo src/appcues/snippets.js "https://$API_HOST/v1/accounts/APPCUES_ACCOUNT_ID/snippets.js"
                    1. Optionally, check that the file matches what Appcues published. These two commands print the same value when it does.
                    curl -fs https://fast.appcues.com/bundle/accounts/APPCUES_ACCOUNT_ID/settings | jq -r .snippets.integrity
                    echo "sha384-$(openssl dgst -sha384 -binary src/appcues/snippets.js | openssl base64 -A)"
                    1. Commit the file, so snippet changes show up in code review like any other change.
                    2. Import the file after setup() resolves and before identify(). Use a dynamic import(). A static import at the top of a file runs before setup(), when the SDK isn't ready to register snippets, and throws an error.
                    await Appcues.setup('APPCUES_ACCOUNT_ID')
                    await import('./appcues/snippets.js')
                    Appcues.identify('USER_ID')

                    In a TypeScript project, add an empty src/appcues/snippets.d.ts containing export {}; so the import type-checks.

                    1. Repeat steps 1–3 and deploy every time someone publishes a snippet change in Appcues. Until you do, experiences that use a changed snippet run your old copy, and experiences that use a new snippet do nothing.

                    Keep these in mind with Option 2:

                    • Update @appcues/web-sdk and download the snippet file again at the same time. The file calls parts of the SDK that can change between versions.
                    • The file belongs to one Appcues account. If you use a separate account per environment, keep one file per account.
                    • Bundling covers the snippet code. A snippet with external dependencies still loads those scripts at runtime.

                    Confirm it worked

                    Open the Appcues Debugger in your application and check these indicators:

                    1. Installed and Connected to Appcues are green. The Debugger will not open at all if the SDK is not detected.
                    1. Tracking Pages is green. Navigate between pages with the Debugger open — the indicator may flash red briefly during page loads, but it should return to green without a manual refresh.

                    If Tracking Pages stays red:

                    • Confirm the SDK snippet is present on the page you navigated to — Appcues only tracks pages where the snippet is loaded.
                    • Check that enableURLDetection: true is included in your AppcuesSettings. Without it, the SDK won't detect navigation.
                    • If you're using a single-page application framework, the SDK should still detect page changes automatically. If Flows are restarting or disappearing during navigation, see the SPA guide for troubleshooting and manual page tracking options.

                    If both checks pass, the SDK is installed. Next step: identify users and groups.

                    If the SDK isn't loading

                    • The Debugger won't open: Confirm the script tag is in the page source (View Source or Elements tab in DevTools). Check that the Account ID matches the one at the top of Settings > Apps & Installation > Web.
                    • Console shows a Content Security Policy error: Your application's CSP is blocking Appcues. Add the required Appcues domains to your allow list. See Configure Content Security Policies.
                    • SDK loads but experiences don't appear: This is usually an identify issue, not an SDK issue. Make sure you've completed the next step: identify users and groups.
                    • Ad blocker interference: Some ad blockers can prevent the Appcues script from loading. See Ad blockers & Appcues.
                    • Experiences show but JavaScript snippets don't run (NPM): The NPM package doesn't load snippets by default. See Run JavaScript snippets with NPM.

                    Still stuck?

                    Collect the following and email support@appcues.com:

                    • Your Appcues Account ID
                    • The URL where the issue occurs
                    • A screenshot of your browser's console (right-click > Inspect > Console tab)
                    • A screenshot of the Appcues Debugger (if it opens)

                    Related

                    • Identify users and groups — Next step after installing the SDK
                    • Track events in your web app — Final installation step
                    • Host the SDK under your own domain
                    • Supported technologies and frameworks
                    • Prepare your frontend for element targeting

                     

                    install appcues appcues sdk appcues script appcues npm appcues snippet appcues javascript appcues react appcues enableurldetection window global loading appcues page tracking track page

                    Was this article helpful?

                    Yes
                    No
                    Give feedback about this article

                    Related Articles

                    • Identify users and groups
                    • Track events in your web app
                    • Configure Content Security Policies for Appcues
                    • Set up Appcues in a single-page application
                    • Ad Blockers & Appcues
                    Appcues logo

                    Product

                    Why Appcues How it works Integrations Security Pricing What's new

                    Use cases

                    Appcues Integration Hub User Onboarding Software Feature Adoption Software NPS & Surveys Announcements Insights Mobile Adoption

                    Company

                    About
                    Careers

                    Support

                    Developer Docs Contact

                    Resources

                    The Appcues Blog Product Adoption Academy GoodUX Case studies Webinar Series Made with Appcues

                    Follow us

                    Facebook icon Twitter icon grey Linkedin icon Instagram icon
                    © 2022 Appcues. All rights reserved.
                    Security Terms of Service Privacy Policy

                    Knowledge Base Software powered by Helpjuice

                    Expand