If that's the case, then don't we need to move the identify call above the
page calls?


On Tue, Apr 15, 2014 at 2:06 PM, Renzo Lucioni <notifications@github.com>wrote:

> In lms/templates/widgets/segment-io.html:
>
> >
> >    % if user.is_authenticated():
> >
> >      analytics.identify("${ user.id }", {
> > -      email          : "${ user.email }",
> > -      username       : "${ user.username }",
> > -      "Active Flags" : "${ active_flags }",
> > +      "Registered"      : true,
> > +      email             : "${ user.email }",
> > +      username          : "${ user.username }",
> > +      // Count the number of courses in which the user is currently enrolled
> > +      "Enrollment Count": ${ sum(1 for course in user.courseenrollment_set.values() if course['is_active'] == True) },
> > +      "Active Flags"    : "${ active_flags }",
>
> After reading through the Segment.io and Mixpanel documentation and
> speaking with Segment.io's support team, I've concluded that metadata from
> the preceding identify call is associated with each event, and that calls
> of Segment.io's library functions are always executed in the order they're
> sent. Here's the behavior we can expect:
>
> analytics.identify("10", { "foo": "bar" });
> foo trait sent to Mixpanel and superproperty saved
>
> analytics.track("Problem Checked");
> foo: bar sent as an *event property* (since it's a superproperty)
>
> analytics.track("Problem Checked");
> foo: bar sent as an *event property* (since it's a superproperty)
>
> analytics.identify("10", { "foo": "baz" });
> foo trait updated and Mixpanel superproperty updated
>
> analytics.track("Problem Checked");
> foo: baz sent as an *event property* (since it's the new value of the foo
> super property)
>
> In this case, filtering by foo == bar will return two events, and
> filtering by foo == baz will return one event.
>
> The page function behaves just like track when passed a name (e.g.,
> analytics.page('Home');).
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/edx/edx-platform/pull/3302/files#r11648491>
> .
>