Renamed to rielas/measurement. It is published under that name, and new versions come out there.
Versions published as anatol-1988/measurement still install under that name. 1 version of 4 come from the new location (see their notes). 3 versions could not be recovered and cannot be installed.
Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/rielas/measurement exists but has no tag 1.1.0; Software Heritage has not archived the repo; no fork with tag 1.1.0 found (11 same-name repos checked); no cached copy. Use another version.
This package helps you to work with Google Analytics Measurement protocol.
Let's send page view event to the Google Analytics:
import Measurement as GA
import Parameter
import Http
GA.post
{ hitType = HitType.Pageview
, trackingId = "UA-123456-1"
, clientId = "555"
, payload = [ Parameter.DocumentPath "/pageA" ]
}
|> Http.postThis will construct Measurement Protocol hit and send it to the POST /collect
endpoint. You can check your request with Hit Builder.
For environments where you can not send POST data, you can also send HTTP GET requests.
import Measurement as GA
import Parameter
import Http
GA.get
{ hitType = HitType.Event
, trackingId = "UA-XXXXX-Y"
, clientId = "555"
, payload =
[ Parameter.CacheBuster "289372387623"
, Parameter.EventCategory "video"
, Parameter.EventAction "play"
, Parameter.EventLabel "holiday"
, Parameter.EventValue 300
]
}
|> Http.getTo send multiple hits in a single request, use batch mode.
import Measurement as GA
import Parameter
import Http
GA.batch
[ { hitType = HitType.Event
, trackingId = "UA-XXXXX-Y"
, clientId = "555"
, payload =
[ Parameter.CacheBuster "289372387623"
, Parameter.EventCategory "video"
, Parameter.EventAction "play"
, Parameter.EventLabel "holiday"
, Parameter.EventValue 300
]
}
, { hitType = HitType.Pageview
, trackingId = "UA-123456-1"
, clientId = "5555"
, payload = [ Parameter.DocumentPath "/pageA" ]
}
]
|> Http.post