Uncaught TypeError: Cannot read properties of undefined (reading 'shift')

I am getting a TypeError from sp.js in my javascript console - anybody know what the issue could be?

The error is:
Uncaught TypeError: Cannot read properties of undefined (reading 'shift')

Given this is a third party script, I am not sure how to go about resolving the error. I have installed the latest sp.js from Snowplow.

Hi @Bryan_Russo would you be able to share exactly what version of the Javascript Tracker you are using and as much of the script you are using here as well?

This is a pretty obscure error so to help we are going to need as much detail as you can provide!

Hi Josh, thanks for the reply.

I am using this version of the tracker: Release Version 3.23.1 · snowplow/snowplow-javascript-tracker · GitHub (sp.js).

Here’s what my script looks like:

(function (p, l, o, w, i, n, g) { if (!p[i]) { p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || []; p.GlobalSnowplowNamespace.push(i); p[i] = function () { (p[i].q = p[i].q || []).push(arguments) }; p[i].q = p[i].q || []; n = l.createElement(o); g = l.getElementsByTagName(o)[0]; n.async = 1; n.src = w; g.parentNode.insertBefore(n, g) } }(window, document, "script", '/js/sp.js', "snowplow"));

const collectorUrl = "..."

snowplow('newTracker', 'sp', collectorUrl, {
  appId: 'my-app-id',

snowplow('enableActivityTracking', {
  minimumVisitLength: 30,
  heartbeatDelay: 10


@josh does anything jump out? I’ve added more detail in my previous comment. Let me know if any further details would be helpful. Thanks!

Usually you get this if you include sp.js without using the snippet that sets up GlobalSnowplowNamespace, but from your snippet above that looks OK.

Is there a second include on your page somewhere that tries to load sp.js?

@jethron yes there was! Thank you so much for the help