Snowplow network_userid variable in copied Google Analytics events

Purpose

See the complete customer journey of our users

Actual configuration

  • Snowplow JavaScript Tracker v2.12.0 (implemented through Google Tag Manager)
  • CustomTask for Google Analytics Events
  • Snowplow Scala Stream PubSub Collector v1.0.1
  • Snowplow Scala Enricher
  • Snowplow BigQuery Loader v0.5.1

Explored paths

1. Snowplow network_userid transmitted in payload

As seen in the Snowplow documentation, the AcceptedQueryParameters show that the Scala Adapter accepts the nuid variable.

Therefore, we tried to transmit that variable in the payload itself. That did not work - transmitted as a query parameter, the network_userid is to be seen in the BigQuery Table.

Unfortunately, the network_userid cannot be loaded as a Javascript variable. Since the cookie, where the network_userid is to be found, is set in HttpOnly and secure and we believe that this makes our setup more robust against mechanisms that try to protect the users privacy and might accidentally block our legit measuring in their efforts.

2. Snowplow domain_userid transmitted in payload

Same principle than the one with the network_userid.
Unfortunately, the domain_userid variable is not accepted by the Scala Adapter. We do not know if editing the code of the GoogleAnalyticsAdapter.scala would:

  • help us populating the Google Analytics events with the domain_userid in the Google BigQuery table.
  • have consequences on our existing configuration.

3. Snowplow Cookie x2

Based on path #1, the Scala stream collector would not only set the httpOnly cookie but a second identical one, which does not have an httpOnly header. Therefore, the cookie would also be readable from the customTask and could be added as parameter to the Google Analytics Snowplow payload.

Do you have any thoughts and/or ideas on these paths?

In case, we’d find the solution on our own, we would of course add that to this thread.

1 Like

Hi @rfort.ewolff

I’m a tad confused by your end goal here, is there a reason the existing network_userid is not enough for your purpose? Or is the goal to send this cookie to GA as well?

The _sp cookie that is returned by the collector is generally a long lived first party cookie (assuming your collector is on the same domain (or subdomain) as your site) so is particularly useful for building a complete user journey on your Snowplow data.

If you want to pass the _sp cookie to Google Analytics then you can do so by removing the httpOnly attribute of the cookie by changing your collector configuration (see here) and then read it in JavaScript. Bare in mind changing this will open up your site to man-in-the-middle attacks where this value could be read by other third party javascript tooling that you are using on your site.

1 Like

Hi Paul,

We could finally find a solution based on your answer.

The request.withCredentials = true; had to be added in the customTask code between request.open and request.setRequestHeader().

Now, we’re trying to get the session_userid through the cookies extractor enrichment.

Thanks for your help!

1 Like