Uncaught Type Error: Cannot Read 'length' of Undefined


When a URL has a trailing slash in it, the SnowPlow js script throws an error:

Uncaught TypeError: Cannot read property 'length' of null
    at g (lnATJXGQ9zZtMi42LjA=.js:37)
    at lnATJXGQ9zZtMi42LjA=.js:37
    at lnATJXGQ9zZtMi42LjA=.js:31
    at eval (eval at ar (lnATJXGQ9zZtMi42LjA=.js:49), <anonymous>:10:9)
    at Function.ax (lnATJXGQ9zZtMi42LjA=.js:52)
    at Object.addFormListeners (lnATJXGQ9zZtMi42LjA=.js:31)
    at Array.<anonymous> (lnATJXGQ9zZtMi42LjA=.js:73)
    at s (lnATJXGQ9zZtMi42LjA=.js:59)
    at HTMLDocument.t (lnATJXGQ9zZtMi42LjA=.js:59)

Example (foo) URL: example.com/some/url/ will throw an error.

If adding something as simple as a # to the end of the URL, the error does not occur.

Example (foo) URL: example.com/some/url/# will NOT throw an error.

Adding a query param however does NOT remove the error.

Example (foo) URL: example.com/some/url/?foo will throw an error.

It appears as though SnowPlow is assuming that if there is a trailing / there will always be a value following.

The little info I have regarding implementation is the following:

  1. The version is 2.6.0
  2. The script is inserted into the document via Google Tag Manager
  3. The following (although obfuscated) code is the guilty party:
d.getCssClasses = function(i) {
    return i.className.match(/\S+/g)
 function g(j, n) {
    var m = d.getCssClasses(j), l;
        for (l = 0; l < m.length; l++) { // !! THIS IS THE OCCURRENCE OF THE ERROR !!
            if (n[m[l]]) {
                return true
    return false

Any info would be much appreciated. Thanks!


Can you add:

  • What version of the JS tracker you are using
  • How you are initialising the JS tracker on the page (ideally the full HTML with the initialisation and events firing)
  • What event(s) are firing that are raising this error


Version of js tracker: V2.6.2


Sorry i will redo the text


I have updated the original ticket to contain more information.


Hi @simon.dowdles - v.2.6.2 is from summer 2016 - can you upgrade and let us know if the issue is still there?


Hey Alex,

Sure, can you please point me in the direction of the latest JS tracker file? Appreciate your time on responding to this matter.



Hey @simon.dowdles,

As per docs latest JavaScript tracker located at d1fc8wv8zag5ca.cloudfront.net/2.8.2/sp.js.

However, we recommend you to not use publicly-hosted asset, but host it yourself with different name as many AdBlockers filter out request for this asset.