mixpanel_plug v0.1.0 MixpanelPlug View Source
Mixpanel tracking as a plug.
- Track events with useful context like referrer, user agent information, and UTM properties
- Keep user profiles up to date on every request
- Respects ‘Do Not Track’ request headers
Link to this section Summary
Functions
Checks for the ‘Do Not Track’ request header and if it exists, assigns its
value to the connection. In the case that tracking is permitted,
update_profile
will be called with the value of an assign named
current_user
from the connection. The value of current_user
must pattern
match the type user/0
. If this is not matched, the user’s profile will not
be updated.
Tracks an event in Mixpanel.
Checks whether the 'Do Not Track' header has been set on the connection
Updates a user profile in Mixpanel. This method pattern matches the value of
the user
struct against the type user/0
. If this is not matched, the
user’s profile will not be updated.
Link to this section Types
user() View Source
Link to this section Functions
call(conn, opts)
View Source
call(Plug.Conn.t(%{assigns: %{current_user: user()}}), Plug.opts()) ::
Plug.Conn.t()
call(Plug.Conn.t(%{assigns: %{current_user: user()}}), Plug.opts()) :: Plug.Conn.t()
Checks for the ‘Do Not Track’ request header and if it exists, assigns its
value to the connection. In the case that tracking is permitted,
update_profile
will be called with the value of an assign named
current_user
from the connection. The value of current_user
must pattern
match the type user/0
. If this is not matched, the user’s profile will not
be updated.
init(opts) View Source
track(conn, event, properties \\ %{})
View Source
track(Plug.Conn.t(), event :: String.t(), properties :: struct()) ::
Plug.Conn.t()
track(Plug.Conn.t(), event :: String.t(), properties :: struct()) :: Plug.Conn.t()
Tracks an event in Mixpanel.
This is a noop if the ‘Do Not Track’ header is set.
Examples
MixpanelPlug.track(conn, "Added To Wishlist")
MixpanelPlug.track(conn, "Discount Code Used", %{"Value" => "10"})
tracking_disabled?(conn)
View Source
tracking_disabled?(Plug.Conn.t()) :: boolean()
tracking_disabled?(Plug.Conn.t()) :: boolean()
Checks whether the 'Do Not Track' header has been set on the connection
Examples
iex> MixpanelPlug.tracking_disabled?(conn)
true
update_profile(conn, user)
View Source
update_profile(Plug.Conn.t(), user :: user()) :: Plug.Conn.t()
update_profile(Plug.Conn.t(), user :: user()) :: Plug.Conn.t()
Updates a user profile in Mixpanel. This method pattern matches the value of
the user
struct against the type user/0
. If this is not matched, the
user’s profile will not be updated.
This is a noop if the ‘Do Not Track’ header is set.
Examples
MixpanelPlug.update_profile(conn, %{id: 1, name: "Callum", email: "callum@example.com"})