Go implementations of event tracking.
You will need:
- a configured input feed for mparticle for your api key and secret.
- the url which in most cases is
https://s2s.mparticle.com/v2
- your types generated from your data plan.
First install using go get github.com/utilitywarehouse/trackers-go
Then you need to import the tracker and use your configured mparticle input feed.
httpClient := &http.Client{
Timeout: 5 * time.Second,
}
tracker := mparticle.NewMParticleTracker("url", "key", "secret", httpClient, true)
Then an event can be tracked by calling the track
method.
err := tracker.Track(
context.Background(),
trackers.NoSchema,
&schema.Identity{CustomerPersonId: trackers.CustomerPersonIDFromAccountNumber("0000000")},
[]trackers.Event{
&schema.HomeInsuranceQuoteAttemptedEvent{
QuoteId: "abc",
QuoteReference: "fef",
Product: schema.ProductContents,
QuoteType: schema.QuoteTypeRenewal,
},
},
[]trackers.Attribute{
schema.HomeInsuranceRenewalDateAttribute("2016-01-21"),
},
)