Schema for global JS object context?


I want to capture a global JS object as a pageview context so that I can query its contents using Snowflake’s JSON capability.

Is there an existing IGLU schema I can use for that, or would I need to set one up myself?

If the latter, would I need to use string for the JSON datatype?


Hi Iain,

You’ll need to set your own one up and I think you’ll need to define the keys as fields within the object.

You can use the ‘object’ datatype in the schema.



Thanks Colm,

I won’t know the keys in the object in advance, so I’d like to store in a similar manner to the old-style unstructured events, with an object name as a field, and then the contents in another field.

Is object datatype still the best option for that?


Ah I see.

So that’s an atypical use case and is kind of contrary to the Snowplow approach as we’re all about data quality and control at collection - ideally you’ll know what you’re getting and define it up front.

However, if you need to do it there’s two things you can try.

Firstly, if you can cast it, cast to string and send it as into a string field. You can then use Snowflake SQL to interpret the string as a JSON.

Secondly, you’d need to test this for the Snowflake loader, but the GCP loader will interpret a field defined as [“object”, “string”] as a JSON string. So if you send it a JSON object it’ll land in DB as a stringified JSON.

There are some similarities in the two loaders under the hood but I haven’t tested this for Snowflake so it might not work. If you can’t cast the value this is an option - but if it does work I can’t say that will never change in the future.

Hope that helps.


Thanks Colm, I’ll give it a try and report back!