how to call snowplow javascript event manually

148 views
Skip to first unread message

Mitul Shah

unread,
Dec 9, 2015, 10:27:19 AM12/9/15
to Snowplow
I'm storing cookie of anonymous user until I haven't user's email.
when user register his email in form, I want to set email as UserID. 

So I though I should have call snowplow event again when submit button is press and same time email value should be set 
window.snowplow('setUserId', emailvalue);

I'm attaching my full code below

window.snowplow('newTracker', 'cf', 'dlfshzdhg01m3.cloudfront.net',
 
{ appId: 'Acds51',
platform
: platformval,
cookieDomain
: "ec2-52-91-83-06.compute-1.amazonaws.com",
cookieName
: "_sp534_", encodeBase64: false, respectDoNotTrack: false,
userFingerprint
: true,
userFingerprintSeed
: 18785926734,
pageUnloadTimer
: 0,
forceSecureTracker
: true,
useCookies
: true,
bufferSize
: 5, maxPostBytes: 45000,
contexts
: { webPage: true, performanceTiming: true, gaCookies: true, geolocation: true }});
window
.snowplow('enableActivityTracking', 30, 10);
window
.snowplow('trackPageView');
window
.snowplow('enableLinkClickTracking', null, true);
window
.snowplow('refreshLinkClickTracking');
if(emailval.length > 0)
{ window.snowplow('setUserId', emailval);
}else{ window.snowplow('setUserIdFromCookie', '_sp534_id.e93d');}


2nd Question is I set value of Platform  is platformval (where platformval either "mob" or "web"). when user opens link using web browser I'm setting "web" otherwise it takes "mob"
Is it correct? please suggest me 

Fred Blundun

unread,
Dec 9, 2015, 10:40:43 AM12/9/15
to snowpl...@googlegroups.com
Hi Mitul,

Your code looks fine to me, assuming that the "emailval" variable is an empty string when you don't have the user's email address.

You aren't using POST, so you can get rid of the "bufferSize" and "maxPostBytes" settings.

There is little benefit in setting the user ID from the cookie set by Snowplow when you don't have the email address, because the JavaScript Tracker automatically sends the information in that cookie anyway.

Regards,
Fred

--
You received this message because you are subscribed to the Google Groups "Snowplow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snowplow-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Dean

unread,
Dec 9, 2015, 10:43:26 AM12/9/15
to Snowplow
> There is little benefit in setting the user ID from the cookie set by Snowplow when you don't have the email address, because the JavaScript Tracker automatically sends the information in that cookie anyway.

Indeed - duplicating the domain_userid into the userid field whenever email is null will make analysis harder not easier...

A
--
Co-founder
Snowplow Analytics
The Roma Building, 32-38 Scrutton Street, London EC2A 4RQ, United Kingdom
+44 (0)203 589 6116
+44 7881 622 925
@alexcrdean

Mitul Shah

unread,
Dec 9, 2015, 11:28:55 PM12/9/15
to Snowplow
Thanks Fred and Alex, thanks for quick answer, it was really helpful me. 

Alex, you're correct I shouldn't override domain_userid into userid field --really good suggestion
Reply all
Reply to author
Forward
0 new messages