US English (US)
ES Spanish

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.

  • Appcues Certifications & Training
  • Integration Hub
  • Contact Us
English (US)
US English (US)
ES Spanish
  • Docs home
  • Installation & Developers
  • Troubleshooting

Using Appcues with RequireJS (Developer)

Learn how to Appcues can be used with AMD loaders like RequireJS.

Updated at June 18th, 2024

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

  • Installation & Developers

    • Web Experiences

      • Mobile Experiences

        • Workflows

          • Analytics & Data

            • Account Management

              • Best Practices

                • Integrations

                  Table of Contents

                  Loading Appcues as a window global while RequireJS is present on the page Loading Appcues as a module in your application

                  Appcues can be used with AMD loaders, like RequireJS. If you used an AMD loader on your site, you'll want to read this doc. There are two scenarios:

                  • You're loading Appcues as a window global and don't want it registered as module within your application
                  • Or, you're trying to load Appcues as a module inside your application

                  Loading Appcues as a window global while RequireJS is present on the page

                  If your site uses an AMD loader, like RequireJS, to load modules, Appcues will attempt to define itself as a module once it detects the AMD loader on the page. If you're not actually planning to use Appcues as module in your application but instead want it be defined as window global, you'll need to set an option on the page to tell the Appcues script to defer defining itself as an AMD module and instead proceed to define itself as a window global. This can be accomplished by adding an AppcuesSettings object to the window. This code should be placed directly before the <script> tag for the Appcues:

                  <script type="text/javascript">
                    window.AppcuesSettings = {
                      skipAMD: true
                    };
                  </script>

                  Loading Appcues as a module in your application

                  If you'd like to load Appcues through an AMD loader, like RequireJS, you can load it using the following snippet:

                  requirejs.config({    
                    "paths": {
                      "appcues": "//fast.appcues.com/<your_appcues_id>.js"    
                    }
                  });

                  Later in your app, you can access the Appcues library with something like this:

                  // As an example,  we identify the user
                  define(['models/user', 'appcues'], function(user, Appcues) {
                    Appcues.identify(user.id, {
                      email: user.email,
                      name: user.first_name + ' ' + user.last_name    
                    });
                  });
                  requirejs amd loaders load appcues as a module inside your application loading appcues as a window global

                  Was this article helpful?

                  Yes
                  No
                  Give feedback about this article

                  Related Articles

                  • Requirements for Using Appcues
                  • Using Appcues with iFrames
                  • Anonymous Users (Developer)
                  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 Appcues University

                  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