Customers

Add customers, segment them, and record their activity.

client.Customers, client.Segments and client.Activity keep Goomzo in step with your own system. See Customers.

Add or update customers

saved, err := client.Customers.Create(ctx, goomzo.CustomerCreateParams{
	IfExists: "update",
	Customers: []goomzo.NewCustomer{{
		Name:       "Amina Juma",
		Phone:      "+255712345678",
		Attributes: map[string]any{"plan": "gold"},
		Segments:   []goomzo.SegmentRef{{Name: "Shoppers"}},
		Activities: []goomzo.ActivityInput{{Key: "purchased", Value: "Shoes"}},
	}},
})

saved[0].Result // "created", "updated" or "unchanged"

Record customer activity

_, err := client.Activity.Record(ctx, goomzo.ActivityRecordParams{
	Phone:      "+255712345678",
	Activities: []goomzo.ActivityInput{{Key: "purchased", Value: "Shoes"}, {Key: "spent", Value: 45000}},
})

Segments

for customer, err := range client.Segments.Customers.List(ctx, "seg_4hq2v9n1c8x0t6pk") {
	if err != nil {
		return err
	}
	fmt.Println(customer.Name)
}

_, err := client.Segments.Customers.Add(ctx, "seg_4hq2v9n1c8x0t6pk", []string{"cus_4hq2v9n1c8x0t6pk"})

Other methods

MethodDoes
Customers.List(ctx, params)Lists customers, a page at a time.
Customers.Get(ctx, id)Gets one.
Customers.Update(ctx, id, changes)Changes one.
Customers.Delete(ctx, id)Deletes one.
Customers.Segments.Set(ctx, id, names)Sets the segments a customer is in.
Customers.Activity.List(ctx, id)Lists a customer's activity.
Segments.Create(ctx, segment)Adds a segment, by hand or by rules.
Segments.Customers.Remove(ctx, id, ids)Takes customers out of a segment.

Next steps

Last updated