Global Contexts not being attached to request body

I’m working on adding global contexts which are consistent across our application suites. However, for some reason I can’t get them to send to our tracker. In the example below I tried adding multiple contexts as I originally had just one call (with multiple contexts), but regardless of which approach none end up being sent down the wire.

window.snowplow('newTracker', 'cf', 'our-tracker', {"appId":"'5f39c9a3-7a78-4ad0-bc98-066f3a77cec4'","discoverRootDomain":true,"cookieName":"'_client_snowplow_'","cookieLifetime":63072000,"stateStorageStrategy":"cookieAndLocalStorage","resetActivityTrackingOnPageView":false,"contexts":{"webPage":true,"performanceTiming":true}});

window.snowplow('addGlobalContexts', [[{"accept":"iglu:co.acme/*/jsonschema/*"},{"schema":"iglu:co.acme/user/jsonschema/1-0-0","data":{"user_id":"U-9ac1fc3b-7919-4f71-b38a-86aeb4562c22"}}]]);

window.snowplow('addGlobalContexts', [[{"accept":"iglu:co.acme/*/jsonschema/*"},{"schema":"iglu:co.acme/partner/jsonschema/1-0-0","data":{"partner_id":"ABC"}}]]);


window.snowplow('enableActivityTracking', 30, 10);


Are you wanting to attach this context to every event or just a subset of events?

window.snowplow('addGlobalContexts', [[{"accept":"iglu:co.acme/*/jsonschema/*"},{"schema":"iglu:co.acme/partner/jsonschema/1-0-0","data":{"partner_id":"ABC"}}]]);

At the moment this only conditionally attaches a context is the schema matches iglu:co.acme/*/jsonschema/* (which page view / page pings etc won’t).

If instead you want to attach to every event you can remove the conditional filter to attach it to every event.

window.snowplow('addGlobalContexts', [{"schema":"iglu:co.acme/user/jsonschema/1-0-0","data":{"user_id":"U-9ac1fc3b-7919-4f71-b38a-86aeb4562c22"}}]);


But of course…silly mistake. Thanks!

1 Like

No worries. I think it’s probably a good opportunity to update the docs with some example scenarios - I could only find ones from the initial release blog post.

1 Like

I couldn’t agree more! It’s in my backlog to update the global contexts docs when we release 2.15.0.

Which is also nearly ready, bar one rather tricky bug we’re trying to solve (You can thank Internet Explorer for the delay).

1 Like

I’ver never thanked IE for anything over the years except for a persistent headache :slight_smile: