Using another name for window.snowplow

Hello !

I was simply wondering if it is safe to rename the javascript function window.snowplow to anything else when fetching the sp.js file, like this:

    <script type="text/javascript" async=1>
        ; (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", "https://myhost.com/sp.js", "anotherName"));
    </script>

Thanks

Hello,

Yes! That is the correct way to rename the attribute where to mount the tracker APIs in the window object. You would then use it like window.anotherName('trackPageView')

2 Likes