Meter v0.1.0 Meter
Meter
Track your elixir functions on Google Analytics
This module define one function to track function calls on google analtycs. The functions load parameters from the configuration. Minimum parameter to enable the tracking is :tid (that is the monitoring id from google analytics eg UA-12456132-1
). A default param_generator
function is provided to generate the request to google analtycs.
Configure the module
config :meter,
tid: "UA-123123123-1", #to track functions this is requested
param_generator: &Meter.Utils.param_generator/5 # the default function, could be replaced,
mapping: [
cid: :arg1, # a value to identify the user, is extracted from the function arguments, if not provided GA generate one for each request
ds: "server", # data source, "server" is the default
t: "pageview" # hit type, default is "pageview" ],
custom_dimensions: [:arg1, :arg2] # custom dimensions to send to ga, it mantain the order, to be used need additional configuration on ga
Summary
Functions
Track a function and its own arguments
Macros
Replace a function definition, automatically tracking every call to the function on google analytics
Functions
Specs
Track a function and its own arguments
Get :tid
, :mapping
and :custom_dimension
from configuration. If :tid
is not defined does nothing.
The request to google analytycs is send asynchronously.
Macros
Replace a function definition, automatically tracking every call to the function on google analytics.
This macro intended use is with a set of uniform functions that can be concettualy mapped to pageviews (eg: messaging bot commands).
Example:
defmeter function(arg1, arg2), do: IO.inspect({arg1,arg2})
function(1,2)
will call track with this parameters
track(:function, [arg1: 1, arg2: 2])
Additional parameters will be loaded from the configuration