• Resolved mythily

    (@mythily)


    Hi

    after adding the below js code for one page, and started testing It is not working and getting the below error

    Error: Uncaught TypeError: nab.trigger is not a function

    JS Code:

    <script type="text/javascript">
    setTimeout( function() {
      nab.trigger( 'time-10s' );
    }, 10000 );
    setTimeout( function() {
      nab.trigger( 'time-30s' );
    }, 30000 );
    setTimeout( function() {
      nab.trigger( 'time-60s' );
    }, 60000 );
    setTimeout( function() {
      nab.trigger( 'time-90s' );
    }, 90000 );
    ( function() {
      [ 30, 50, 75, 100 ].forEach(
        ( threshold ) => document.addEventListener( 'scroll', () => {
          const bottom = window.pageYOffset + window.innerHeight;
          const scroll = 100 * bottom / document.body.clientHeight;
          if ( scroll >= threshold ) {
            nab.trigger( scroll-${ threshold } );
          }
        } )
      );
    } )();
    </script>

Viewing 1 replies (of 1 total)
  • Plugin Author David Aguilera

    (@davilera)

    You have to make sure that our tracking script is properly loaded on your site. For example, if you’re using a cache plugin, purge your cache after starting a test.

    Also, exclude our tracking script from being optimized, combined, deferred, etc — you want to make sure it’s loaded as soon as possible without any “speed optimizations.”

    Finally, when using a global function such as nab.trigger, it’s usually a good idea to wrap the call in an if statement and check if it’s available. Something like this:

    <script type="text/javascript">
    (function() {
      if ( ! nab.trigger ) return;
    
      setTimeout( function() {
        nab.trigger( 'time-10s' );
      }, 10000 );
      // ...
    })()
    </script>

    If none of this works, please let me know the URL of your site and I’ll look into it.

Viewing 1 replies (of 1 total)
  • The topic ‘Uncaught TypeError: nab.trigger is not a function’ is closed to new replies.