Page View Attributes

So what Im trying to do is capture page view attributes as you would in adobe or in GA. For example upon loading a page i have created a defined site_id that gets passed defining a sub doamin. Looking into snowplow is says these values get passed as “cx” call based on a structured event. I need this attribute to be passed at the page view level not upon a strutured event call, is this possible?
Regards,
Wayne

Hi Wayne,

You could try sending the data as one or more custom context.

You would need to create and upload a schema first, then send the data referencing its matching schema, as per the documentation I linked to.

Best of luck!

1 Like

As @Colm has mentioned above you can do this via a custom context via a trackPageView call (which in this case would contain your site_id) e.g.,

window.snowplow_name_here('trackPageView', null, [{
    schema: "iglu:com.example_company/page/jsonschema/1-0-0",
    data: {
        site_id: "example"
    }
}]);

this will allow you to join any of the contexts you send through to the core page_view event.

2 Likes

Thanks!

Old post but this was useful thanks @mike !

I was struggling to get custom contexts to attach to trackPageViews by going off the example javascript snippet at the bottom of this page: Predefined vs custom entities - Snowplow Docs

Maybe I was interpreting the page wrong, but the example given is not structured correctly?

The example structure that doesn’t work is:

window.snowplow(
‘trackPageView’,
{
context: [{ // array of custom contexts
schema: “iglu:com.example_company/page/jsonschema/1-2-1”,
data: {
pageType: ‘test’,
lastUpdated: new Date(2016,3,10)
}
},
{
schema: “iglu:com.example_company/user/jsonschema/2-0-0”,
data: {
userType: ‘tester’,
}
}]
});

Your example Mike works fine.

Thanks again

1 Like

No worries - the example I posted above (a few years back) should work fine in JS 2.x versions of the tracker but the example on that post is for the Javascript 3.x trackers (very recently released) which has a slightly different API to earlier versions.

I’ve updated the page to include v3 and v2 examples now rather than just a v3 example since this is in a generic part of the docs and isn’t version specific :slight_smile:

1 Like