Documentation
¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func DefaultClientOptions() []option.RequestOption
- func F[T any](value T) param.Field[T]
- func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type AccountService
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, ...) error
- func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- type Error
- type EventDeleteByNameParams
- type EventListParams
- type EventNewParams
- type EventNewParamsCurrency
- type EventService
- func (r *EventService) Delete(ctx context.Context, siteID string, eventID string, ...) (err error)deprecated
- func (r *EventService) DeleteByName(ctx context.Context, siteID string, body EventDeleteByNameParams, ...) (err error)
- func (r *EventService) Get(ctx context.Context, siteID string, eventID string, ...) (err error)deprecated
- func (r *EventService) List(ctx context.Context, siteID string, query EventListParams, ...) (err error)
- func (r *EventService) New(ctx context.Context, siteID string, body EventNewParams, ...) (err error)deprecated
- func (r *EventService) SetCurrency(ctx context.Context, siteID string, body EventSetCurrencyParams, ...) (err error)
- func (r *EventService) Update(ctx context.Context, siteID string, eventID string, body EventUpdateParams, ...) (err error)deprecated
- func (r *EventService) Wipe(ctx context.Context, siteID string, eventID string, ...) (err error)deprecated
- type EventSetCurrencyParams
- type EventSetCurrencyParamsCurrency
- type EventUpdateParams
- type EventUpdateParamsCurrency
- type MilestoneListParams
- type MilestoneNewParams
- type MilestoneService
- func (r *MilestoneService) Delete(ctx context.Context, siteID string, milestoneID string, ...) (err error)
- func (r *MilestoneService) Get(ctx context.Context, siteID string, milestoneID string, ...) (err error)
- func (r *MilestoneService) List(ctx context.Context, siteID string, query MilestoneListParams, ...) (err error)
- func (r *MilestoneService) New(ctx context.Context, siteID string, body MilestoneNewParams, ...) (err error)
- func (r *MilestoneService) Update(ctx context.Context, siteID string, milestoneID string, ...) (err error)
- type MilestoneUpdateParams
- type ReportAggregationParams
- type ReportAggregationParamsDateGrouping
- type ReportAggregationParamsEntity
- type ReportCurrentVisitorsParams
- type ReportService
- type SiteListParams
- type SiteNewParams
- type SiteNewParamsMultiDomainOption
- type SiteNewParamsSharing
- type SiteService
- func (r *SiteService) Delete(ctx context.Context, siteID string, opts ...option.RequestOption) (err error)
- func (r *SiteService) Get(ctx context.Context, siteID string, opts ...option.RequestOption) (err error)
- func (r *SiteService) List(ctx context.Context, query SiteListParams, opts ...option.RequestOption) (err error)
- func (r *SiteService) New(ctx context.Context, body SiteNewParams, opts ...option.RequestOption) (err error)
- func (r *SiteService) Update(ctx context.Context, siteID string, body SiteUpdateParams, ...) (err error)
- func (r *SiteService) Wipe(ctx context.Context, siteID string, opts ...option.RequestOption) (err error)deprecated
- type SiteUpdateParams
- type SiteUpdateParamsMultiDomainOption
- type SiteUpdateParamsSharing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment. This should be used to initialize new clients.
Types ¶
type AccountService ¶
type AccountService struct {
Options []option.RequestOption
}
AccountService contains methods and other services that help with interacting with the API. You should not instantiate this service directly, and instead use the NewAccountService method instead.
func NewAccountService ¶
func NewAccountService(opts ...option.RequestOption) (r *AccountService)
NewAccountService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*AccountService) List ¶
func (r *AccountService) List(ctx context.Context, opts ...option.RequestOption) (err error)
Retrieve information about the account that owns the API key.
**Permissions:** Requires a token with full account access (the `*` scope).
**Returns:** An account object.
Parameters:
ctx: Context for the request. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Account.List(context.Background())
if err != nil {
panic(err)
}
func (*AccountService) ListToken ¶
func (r *AccountService) ListToken(ctx context.Context, opts ...option.RequestOption) (err error)
Retrieve metadata about the API token used to make the request, including its name, permissions (abilities), token-format version and timestamps. Your secret token value is never returned.
**Permissions:** Any valid API token.
**Returns:** A token object.
Parameters:
ctx: Context for the request. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Account.ListToken(context.Background())
if err != nil {
panic(err)
}
type Client ¶
type Client struct {
Options []option.RequestOption
Account *AccountService
Sites *SiteService
Events *EventService
Milestones *MilestoneService
Reports *ReportService
}
Client creates a struct with services and top level methods that help with interacting with the Fathom Analytics API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
NewClient generates a new client with the default option read from the environment. The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Post ¶
func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type EventDeleteByNameParams ¶
type EventDeleteByNameParams struct {
// The name of the event you wish to delete. Example: `Purchase early access`
Name param.Field[string] `query:"name" api:"required"`
}
func (EventDeleteByNameParams) URLQuery ¶
func (r EventDeleteByNameParams) URLQuery() (v url.Values)
URLQuery serializes EventDeleteByNameParams's query parameters as `url.Values`.
type EventListParams ¶
type EventListParams struct {
// A cursor for use in pagination, working in the opposite direction to
// `starting_after`. `ending_before` is an object ID that defines your place in the
// list.
EndingBefore param.Field[string] `query:"ending_before"`
// A limit on the number of objects to be returned, between 1 and 100.
Limit param.Field[int64] `query:"limit"`
// A cursor for use in pagination. `starting_after` is an object ID that defines
// your place in the list. For example, if you make a list request and receive 10
// objects ending with `obj_foo`, your subsequent call can include
// `starting_after=obj_foo` to fetch the next page.
StartingAfter param.Field[string] `query:"starting_after"`
}
func (EventListParams) URLQuery ¶
func (r EventListParams) URLQuery() (v url.Values)
URLQuery serializes EventListParams's query parameters as `url.Values`.
type EventNewParams ¶
type EventNewParams struct {
// The name of the event (up to 255 characters). Example: `Purchase early access`
Name param.Field[string] `json:"name" api:"required"`
// The currency used for any value attached to this event's completions. If
// omitted, defaults to `dollar`.
Currency param.Field[EventNewParamsCurrency] `json:"currency"`
}
func (EventNewParams) MarshalJSON ¶
func (r EventNewParams) MarshalJSON() (data []byte, err error)
type EventNewParamsCurrency ¶
type EventNewParamsCurrency string
const ( EventNewParamsCurrencyDollar EventNewParamsCurrency = "dollar" EventNewParamsCurrencyPound EventNewParamsCurrency = "pound" EventNewParamsCurrencyEuro EventNewParamsCurrency = "euro" EventNewParamsCurrencyYuan EventNewParamsCurrency = "yuan" EventNewParamsCurrencyPeso EventNewParamsCurrency = "peso" EventNewParamsCurrencyShekel EventNewParamsCurrency = "shekel" EventNewParamsCurrencyYen EventNewParamsCurrency = "yen" EventNewParamsCurrencyWon EventNewParamsCurrency = "won" EventNewParamsCurrencyHryvnia EventNewParamsCurrency = "hryvnia" EventNewParamsCurrencyFranc EventNewParamsCurrency = "franc" EventNewParamsCurrencyRupee EventNewParamsCurrency = "rupee" EventNewParamsCurrencyInteger EventNewParamsCurrency = "integer" EventNewParamsCurrencyNone EventNewParamsCurrency = "none" )
func (EventNewParamsCurrency) IsKnown ¶
func (r EventNewParamsCurrency) IsKnown() bool
type EventService ¶
type EventService struct {
Options []option.RequestOption
}
EventService contains methods and other services that help with interacting with the API. You should not instantiate this service directly, and instead use the NewEventService method instead.
func NewEventService ¶
func NewEventService(opts ...option.RequestOption) (r *EventService)
NewEventService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*EventService) Delete
deprecated
func (r *EventService) Delete(ctx context.Context, siteID string, eventID string, opts ...option.RequestOption) (err error)
Previously deleted an event by its goal code. This endpoint is no longer available.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. eventID: The `id` (tracking code) of the event you wish to delete. opts: Options to apply to this request.
Returns:
error: This endpoint is no longer available. To delete an event, use [Delete event](#delete-event-by-name) with the event name.
Example:
err := client.Events.Delete(context.Background(), "CDBUGS", "ABCDEFGH")
if err != nil {
panic(err)
}
Deprecated: this method is deprecated.
func (*EventService) DeleteByName ¶
func (r *EventService) DeleteByName(ctx context.Context, siteID string, body EventDeleteByNameParams, opts ...option.RequestOption) (err error)
Delete an event by its name. If more than one event row shares the name, they are treated as one event and every matching row is deleted.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
**Returns:** Returns a deleted object on success. Otherwise, this call returns an error.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. body: EventDeleteByNameParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Events.DeleteByName(context.Background(), "CDBUGS", sdk.EventDeleteByNameParams{
Name: sdk.F[string]("Purchase early access"),
})
if err != nil {
panic(err)
}
func (*EventService) Get
deprecated
func (r *EventService) Get(ctx context.Context, siteID string, eventID string, opts ...option.RequestOption) (err error)
Previously returned a single event by its goal code. This endpoint is no longer available.
**Permissions:** Requires read access to the site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. eventID: The `id` (tracking code) of the event, as returned when the event was created. opts: Options to apply to this request.
Returns:
error: This endpoint is no longer available. Use [List events](#list-events).
Example:
err := client.Events.Get(context.Background(), "CDBUGS", "ABCDEFGH")
if err != nil {
panic(err)
}
Deprecated: this method is deprecated.
func (*EventService) List ¶
func (r *EventService) List(ctx context.Context, siteID string, query EventListParams, opts ...option.RequestOption) (err error)
Return a list of all events this site owns. Events are sorted by `created_at` ascending to allow you to paginate with ease.
**Permissions:** Requires read access to the site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
**Returns:** A list of event objects.
> **The id field is going away:** Each event still returns an `id` (the old goal code). We are removing that field on 24 September 2026. Identify events by `name` instead.
> The `currency` field is returned as `null` on list responses. Set it with [Set event currency](#set-event-currency).
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. query: EventListParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Events.List(context.Background(), "CDBUGS", sdk.EventListParams{
Limit: sdk.F[int64](10),
})
if err != nil {
panic(err)
}
func (*EventService) New
deprecated
func (r *EventService) New(ctx context.Context, siteID string, body EventNewParams, opts ...option.RequestOption) (err error)
Previously created an event. This endpoint is no longer available.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. body: EventNewParams request parameters. opts: Options to apply to this request.
Returns:
error: This endpoint is no longer available. Track the event on your site, then use [List events](#list-events) and [Set event currency](#set-event-currency).
Example:
err := client.Events.New(context.Background(), "CDBUGS", sdk.EventNewParams{
Name: sdk.F[string]("Purchase early access"),
})
if err != nil {
panic(err)
}
Deprecated: this method is deprecated.
func (*EventService) SetCurrency ¶
func (r *EventService) SetCurrency(ctx context.Context, siteID string, body EventSetCurrencyParams, opts ...option.RequestOption) (err error)
Set the currency of an event by its name. Use this instead of updating an event by its goal code. If more than one event row shares the name, they are treated as one event and every matching row is updated.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
**Returns:** Returns an updated object on success. Otherwise, this call returns an error.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. body: EventSetCurrencyParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Events.SetCurrency(context.Background(), "CDBUGS", sdk.EventSetCurrencyParams{
Name: sdk.F[string]("Purchase early access"),
})
if err != nil {
panic(err)
}
func (*EventService) Update
deprecated
func (r *EventService) Update(ctx context.Context, siteID string, eventID string, body EventUpdateParams, opts ...option.RequestOption) (err error)
Previously updated an event by its goal code. This endpoint is no longer available.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. eventID: The `id` (tracking code) of the event you wish to update. body: EventUpdateParams request parameters. opts: Options to apply to this request.
Returns:
error: This endpoint is no longer available. To change an event's currency, use [Set event currency](#set-event-currency).
Example:
err := client.Events.Update(context.Background(), "CDBUGS", "ABCDEFGH", sdk.EventUpdateParams{})
if err != nil {
panic(err)
}
Deprecated: this method is deprecated.
func (*EventService) Wipe
deprecated
func (r *EventService) Wipe(ctx context.Context, siteID string, eventID string, opts ...option.RequestOption) (err error)
Previously wiped all completion data belonging to an event. This endpoint is no longer available.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. eventID: The `id` (tracking code) of the event. opts: Options to apply to this request.
Returns:
error: This endpoint has been retired and now returns `410 Gone`. It is no longer possible to wipe an event's completion data via the API.
Example:
err := client.Events.Wipe(context.Background(), "CDBUGS", "ABCDEFGH")
if err != nil {
panic(err)
}
Deprecated: this method is deprecated.
type EventSetCurrencyParams ¶
type EventSetCurrencyParams struct {
// The currency used for any value attached to this event's completions.
Currency param.Field[EventSetCurrencyParamsCurrency] `json:"currency" api:"required"`
// The name of the event (up to 255 characters). Example: `Purchase early access`
Name param.Field[string] `json:"name" api:"required"`
}
func (EventSetCurrencyParams) MarshalJSON ¶
func (r EventSetCurrencyParams) MarshalJSON() (data []byte, err error)
type EventSetCurrencyParamsCurrency ¶
type EventSetCurrencyParamsCurrency string
const ( EventSetCurrencyParamsCurrencyDollar EventSetCurrencyParamsCurrency = "dollar" EventSetCurrencyParamsCurrencyPound EventSetCurrencyParamsCurrency = "pound" EventSetCurrencyParamsCurrencyEuro EventSetCurrencyParamsCurrency = "euro" EventSetCurrencyParamsCurrencyYuan EventSetCurrencyParamsCurrency = "yuan" EventSetCurrencyParamsCurrencyPeso EventSetCurrencyParamsCurrency = "peso" EventSetCurrencyParamsCurrencyShekel EventSetCurrencyParamsCurrency = "shekel" EventSetCurrencyParamsCurrencyYen EventSetCurrencyParamsCurrency = "yen" EventSetCurrencyParamsCurrencyWon EventSetCurrencyParamsCurrency = "won" EventSetCurrencyParamsCurrencyHryvnia EventSetCurrencyParamsCurrency = "hryvnia" EventSetCurrencyParamsCurrencyFranc EventSetCurrencyParamsCurrency = "franc" EventSetCurrencyParamsCurrencyRupee EventSetCurrencyParamsCurrency = "rupee" EventSetCurrencyParamsCurrencyInteger EventSetCurrencyParamsCurrency = "integer" EventSetCurrencyParamsCurrencyNone EventSetCurrencyParamsCurrency = "none" )
func (EventSetCurrencyParamsCurrency) IsKnown ¶
func (r EventSetCurrencyParamsCurrency) IsKnown() bool
type EventUpdateParams ¶
type EventUpdateParams struct {
// The currency used for any value attached to this event's completions.
Currency param.Field[EventUpdateParamsCurrency] `json:"currency"`
// The name of the event (up to 255 characters).
Name param.Field[string] `json:"name"`
}
func (EventUpdateParams) MarshalJSON ¶
func (r EventUpdateParams) MarshalJSON() (data []byte, err error)
type EventUpdateParamsCurrency ¶
type EventUpdateParamsCurrency string
const ( EventUpdateParamsCurrencyDollar EventUpdateParamsCurrency = "dollar" EventUpdateParamsCurrencyPound EventUpdateParamsCurrency = "pound" EventUpdateParamsCurrencyEuro EventUpdateParamsCurrency = "euro" EventUpdateParamsCurrencyYuan EventUpdateParamsCurrency = "yuan" EventUpdateParamsCurrencyPeso EventUpdateParamsCurrency = "peso" EventUpdateParamsCurrencyShekel EventUpdateParamsCurrency = "shekel" EventUpdateParamsCurrencyYen EventUpdateParamsCurrency = "yen" EventUpdateParamsCurrencyWon EventUpdateParamsCurrency = "won" EventUpdateParamsCurrencyHryvnia EventUpdateParamsCurrency = "hryvnia" EventUpdateParamsCurrencyFranc EventUpdateParamsCurrency = "franc" EventUpdateParamsCurrencyRupee EventUpdateParamsCurrency = "rupee" EventUpdateParamsCurrencyInteger EventUpdateParamsCurrency = "integer" EventUpdateParamsCurrencyNone EventUpdateParamsCurrency = "none" )
func (EventUpdateParamsCurrency) IsKnown ¶
func (r EventUpdateParamsCurrency) IsKnown() bool
type MilestoneListParams ¶
type MilestoneListParams struct {
// A cursor for use in pagination, working in the opposite direction to
// `starting_after`. `ending_before` is an object ID that defines your place in the
// list.
EndingBefore param.Field[string] `query:"ending_before"`
// A limit on the number of objects to be returned, between 1 and 100.
Limit param.Field[int64] `query:"limit"`
// A cursor for use in pagination. `starting_after` is an object ID that defines
// your place in the list. For example, if you make a list request and receive 10
// objects ending with `obj_foo`, your subsequent call can include
// `starting_after=obj_foo` to fetch the next page.
StartingAfter param.Field[string] `query:"starting_after"`
}
func (MilestoneListParams) URLQuery ¶
func (r MilestoneListParams) URLQuery() (v url.Values)
URLQuery serializes MilestoneListParams's query parameters as `url.Values`.
type MilestoneNewParams ¶
type MilestoneNewParams struct {
// The date of the milestone in `YYYY-MM-DD` format.
MilestoneDate param.Field[string] `json:"milestone_date" api:"required"`
// The name of the milestone (up to 30 characters).
Name param.Field[string] `json:"name" api:"required"`
}
func (MilestoneNewParams) MarshalJSON ¶
func (r MilestoneNewParams) MarshalJSON() (data []byte, err error)
type MilestoneService ¶
type MilestoneService struct {
Options []option.RequestOption
}
MilestoneService contains methods and other services that help with interacting with the API. You should not instantiate this service directly, and instead use the NewMilestoneService method instead.
func NewMilestoneService ¶
func NewMilestoneService(opts ...option.RequestOption) (r *MilestoneService)
NewMilestoneService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*MilestoneService) Delete ¶
func (r *MilestoneService) Delete(ctx context.Context, siteID string, milestoneID string, opts ...option.RequestOption) (err error)
Delete a milestone. Careful: you can't undo this, and neither can we.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
**Returns:** Returns a deleted object on success. Otherwise, this call returns an error.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. milestoneID: The `id` (UUID) of the milestone you wish to delete. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Milestones.Delete(context.Background(), "CDBUGS", "ddc9cdff-ab83-41fa-96c6-dfb276a862e7")
if err != nil {
panic(err)
}
func (*MilestoneService) Get ¶
func (r *MilestoneService) Get(ctx context.Context, siteID string, milestoneID string, opts ...option.RequestOption) (err error)
Return a single milestone.
**Permissions:** Requires read access to the site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
**Returns:** A milestone object.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. milestoneID: The `id` (UUID) of the milestone you wish to retrieve. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Milestones.Get(context.Background(), "CDBUGS", "ddc9cdff-ab83-41fa-96c6-dfb276a862e7")
if err != nil {
panic(err)
}
func (*MilestoneService) List ¶
func (r *MilestoneService) List(ctx context.Context, siteID string, query MilestoneListParams, opts ...option.RequestOption) (err error)
Return a list of all milestones this site owns. Milestones are sorted by `created_at` ascending to allow you to paginate with ease.
**Permissions:** Requires read access to the site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
**Returns:** A list of milestone objects.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. query: MilestoneListParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Milestones.List(context.Background(), "CDBUGS", sdk.MilestoneListParams{
Limit: sdk.F[int64](10),
})
if err != nil {
panic(err)
}
func (*MilestoneService) New ¶
func (r *MilestoneService) New(ctx context.Context, siteID string, body MilestoneNewParams, opts ...option.RequestOption) (err error)
Create a milestone. Returns HTTP `201 Created` on success.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
**Returns:** A milestone object.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. body: MilestoneNewParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Milestones.New(context.Background(), "CDBUGS", sdk.MilestoneNewParams{
MilestoneDate: sdk.F[string]("2024-01-15"),
Name: sdk.F[string]("Website Redesign Launch"),
})
if err != nil {
panic(err)
}
func (*MilestoneService) Update ¶
func (r *MilestoneService) Update(ctx context.Context, siteID string, milestoneID string, body MilestoneUpdateParams, opts ...option.RequestOption) (err error)
Update a milestone. Both `name` and `milestone_date` are required.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
**Returns:** A milestone object.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. milestoneID: The `id` (UUID) of the milestone you wish to update. body: MilestoneUpdateParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Milestones.Update(context.Background(), "CDBUGS", "ddc9cdff-ab83-41fa-96c6-dfb276a862e7", sdk.MilestoneUpdateParams{
MilestoneDate: sdk.F[string]("2024-01-20"),
Name: sdk.F[string]("Website Redesign Launch v2"),
})
if err != nil {
panic(err)
}
type MilestoneUpdateParams ¶
type MilestoneUpdateParams struct {
// The date of the milestone in `YYYY-MM-DD` format.
MilestoneDate param.Field[string] `json:"milestone_date" api:"required"`
// The name of the milestone (up to 30 characters).
Name param.Field[string] `json:"name" api:"required"`
}
func (MilestoneUpdateParams) MarshalJSON ¶
func (r MilestoneUpdateParams) MarshalJSON() (data []byte, err error)
type ReportAggregationParams ¶
type ReportAggregationParams struct {
// The aggregates you wish to include, separated by a comma.
//
// Supported values for **pageview** entities: `visits`, `uniques`, `pageviews`,
// `avg_duration` and `bounce_rate`. The difference between "visits" and "uniques"
// is that visits are unique site visits whilst uniques are unique page visits.
//
// Supported values for **event** entities: `conversions`, `unique_conversions` and
// `value` (value is returned in cents).
Aggregates param.Field[string] `query:"aggregates" api:"required"`
// The entity you want to report on. Events are treated separately from pageviews.
// Supported values: `pageview` and `event`.
Entity param.Field[ReportAggregationParamsEntity] `query:"entity" api:"required"`
// Timestamp (e.g. `2022-04-01 15:31:00`). Should match the timezone you're
// reporting in. Defaults to the entity's first recorded data.
DateFrom param.Field[string] `query:"date_from"`
// By default, we don't do any date grouping and return total aggregations.
// Override this with `hour`, `day`, `month` or `year`. Note: `hour` grouping is
// only supported for date ranges of up to 7 days.
DateGrouping param.Field[ReportAggregationParamsDateGrouping] `query:"date_grouping"`
// Timestamp (e.g. `2022-04-01 15:31:00`). Should match the timezone you're
// reporting in. Default: now.
DateTo param.Field[string] `query:"date_to"`
// When `entity` is `pageview`, this is the `id` of the site you want to aggregate
// on. When `entity` is `event`, do not pass a goal code here. Use `site_id` and
// `entity_name` instead. Pageview usage is unchanged.
//
// **Required when entity is "pageview".**
EntityID param.Field[string] `query:"entity_id"`
// The name of the event you want to report on. Example: `purchase`.
//
// **Required when entity is "event" and entity_id is omitted.**
EntityName param.Field[string] `query:"entity_name"`
// The fields you want to group by, separated by a comma (e.g.
// `hostname,pathname`). Supported values: `hostname`, `pathname`, `entry_page`,
// `exit_page`, `referrer_hostname`, `referrer_pathname`, `referrer_source`,
// `browser`, `country_code`, `city`, `state`, `region`, `device_type`,
// `operating_system`, `utm_campaign`, `utm_content`, `utm_medium`, `utm_source`,
// `utm_term`, `keyword` and `ref`.
FieldGrouping param.Field[string] `query:"field_grouping"`
// A JSON-encoded array of filter objects. See the filtering reference below for
// the full list of supported properties and operators. Each filter's `value` must
// be a string.
Filters param.Field[string] `query:"filters"`
// Optional integer from `1` to `1000` inclusive.
//
// **Default.** When `field_grouping` is set and you omit `limit`, we return at
// most 500 rows. When `field_grouping` is omitted, there is no default row cap.
// `date_grouping` alone does not trigger the 500 default.
//
// **Maximum.** A `limit` above 1000 returns HTTP 400 with an `errors.limit`
// validation message. There is no pagination on this endpoint, so you cannot walk
// past 1000 grouped rows with a cursor. Narrow the result with `filters` and/or a
// shorter `date_from` / `date_to`, then issue more requests.
Limit param.Field[int64] `query:"limit"`
// The `id` of the site the event belongs to.
//
// **Required when entity is "event" and entity_id is omitted.**
SiteID param.Field[string] `query:"site_id"`
// The field you want to sort by, in the format `field:asc|desc`. You can use any
// field present in `aggregates` or `field_grouping`. When using `date_grouping`,
// you can also sort by `timestamp:asc` or `timestamp:desc`. Example:
// `pageviews:desc`
SortBy param.Field[string] `query:"sort_by"`
// **Deprecated.** We now report using each site's configured timezone by default.
// If provided, this [TZ database
// name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) overrides
// the site's timezone for this request. We'll be removing this parameter in the
// future.
Timezone param.Field[string] `query:"timezone"`
}
func (ReportAggregationParams) URLQuery ¶
func (r ReportAggregationParams) URLQuery() (v url.Values)
URLQuery serializes ReportAggregationParams's query parameters as `url.Values`.
type ReportAggregationParamsDateGrouping ¶
type ReportAggregationParamsDateGrouping string
const ( ReportAggregationParamsDateGroupingHour ReportAggregationParamsDateGrouping = "hour" ReportAggregationParamsDateGroupingDay ReportAggregationParamsDateGrouping = "day" ReportAggregationParamsDateGroupingMonth ReportAggregationParamsDateGrouping = "month" ReportAggregationParamsDateGroupingYear ReportAggregationParamsDateGrouping = "year" )
func (ReportAggregationParamsDateGrouping) IsKnown ¶
func (r ReportAggregationParamsDateGrouping) IsKnown() bool
type ReportAggregationParamsEntity ¶
type ReportAggregationParamsEntity string
const ( ReportAggregationParamsEntityPageview ReportAggregationParamsEntity = "pageview" ReportAggregationParamsEntityEvent ReportAggregationParamsEntity = "event" )
func (ReportAggregationParamsEntity) IsKnown ¶
func (r ReportAggregationParamsEntity) IsKnown() bool
type ReportCurrentVisitorsParams ¶
type ReportCurrentVisitorsParams struct {
// The `id` of the site. Example: `CDBUGS`
SiteID param.Field[string] `query:"site_id" api:"required"`
// Set to `true` for a detailed breakdown of pages and referrers. Otherwise you'll
// only get a count.
Detailed param.Field[bool] `query:"detailed"`
}
func (ReportCurrentVisitorsParams) URLQuery ¶
func (r ReportCurrentVisitorsParams) URLQuery() (v url.Values)
URLQuery serializes ReportCurrentVisitorsParams's query parameters as `url.Values`.
type ReportService ¶
type ReportService struct {
Options []option.RequestOption
}
ReportService contains methods and other services that help with interacting with the API. You should not instantiate this service directly, and instead use the NewReportService method instead.
func NewReportService ¶
func NewReportService(opts ...option.RequestOption) (r *ReportService)
NewReportService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ReportService) Aggregation ¶
func (r *ReportService) Aggregation(ctx context.Context, query ReportAggregationParams, opts ...option.RequestOption) (err error)
Build a custom report. Group and filter on the fields you care about.
**Permissions:** Requires read access to the relevant site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
**Returns:** Returns an array of objects. The properties of each object vary based on the aggregates and groupings you've asked for. All numeric values are returned as strings.
> This API endpoint is only accurate on data from March 2021 onwards. Before then, we did not tie browser, country, pathname, etc. together, so we have no way to offer this advanced filtering on that data.
> Grouped reports (`field_grouping`) default to 500 rows unless you set `limit`. The maximum is 1000, and this endpoint has no pagination. BI tools such as Looker Studio / Data Studio that fire many aggregations at once will hit the [concurrency cap](/api/v1/rate-limits), not the row cap. Space those requests, cache one extract per period, or raise the API plan.
> **Goal codes are no longer available:** Reporting on an event by its goal code (`entity_id` with `entity=event`) is no longer available. Report on events using `site_id` and `entity_name` instead. Pageview reporting, where `entity_id` is the site `id`, is unaffected.
#### Filtering
Filters are supplied as a JSON array. Each filter is an object with a `property`, an `operator` and a string `value`. You can add as many filters as you like; see the examples in the code panel.
We support the following operators:
- `is`: exact match - `is not`: everything except an exact match - `is like`: contains the term (supports wildcards `*`) - `is not like`: does not contain the term - `matching`: matches a regular expression (regex) pattern - `not matching`: does not match a regex pattern
**Operator availability depends on the field.** Text-style fields support all six operators; categorical fields support only `is` and `is not`:
- **All six operators:** `domain`, `hostname`, `pathname`, `entry_page`, `exit_page`, `referrer_hostname`, `referrer_pathname`, `referrer_source`, `ref`, `utm_campaign`, `utm_source`, `utm_medium`, `utm_content`, `utm_term` - **`is` / `is not` only:** `device_type`, `operating_system`, `browser`, `country_code`, `city`, `state`, `region`
Note: `domain` can be filtered on but not grouped by, while `keyword` can be grouped by but not filtered on.
##### Entry and exit pages
`entry_page` is the pathname of the first pageview in a visit. `exit_page` is the pathname of the last pageview before the visitor leaves. Both are session-level fields. They mirror the Entry Pages and Exit Pages reports on your dashboard and work for both `field_grouping` and `filters`.
When you filter by `entry_page`, only visits that *entered* on that page are included. A visitor who lands on `/home` and later views `/pricing` is excluded by `{"property": "entry_page", "operator": "is", "value": "/pricing"}`, but included when filtering on `pathname` instead.
##### Regex examples
With `matching` / `not matching` you can build sophisticated filters:
- `^/(about|contact|pricing)$`: match only /about, /contact and /pricing - `^/(about|contact|pricing)`: match paths starting with those - `^/blog/\d{4}/\d{2}/`: match blog URLs like /blog/2025/07/my-post - `^/products/[^/]+/$`: match product category pages
Parameters:
ctx: Context for the request. query: ReportAggregationParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Reports.Aggregation(context.Background(), sdk.ReportAggregationParams{
Aggregates: sdk.F[string]("pageviews"),
Entity: sdk.F[sdk.ReportAggregationParamsEntity](sdk.ReportAggregationParamsEntity("pageview")),
})
if err != nil {
panic(err)
}
func (*ReportService) CurrentVisitors ¶
func (r *ReportService) CurrentVisitors(ctx context.Context, query ReportCurrentVisitorsParams, opts ...option.RequestOption) (err error)
Returns the total number of current visitors on a site. The detailed view also returns the top 150 pages and top 150 referrers.
**Permissions:** Requires read access to the site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
**Returns:** The current visitor count, with an optional detailed breakdown.
Parameters:
ctx: Context for the request. query: ReportCurrentVisitorsParams request parameters. opts: Options to apply to this request.
Returns:
error: Simple
Example:
err := client.Reports.CurrentVisitors(context.Background(), sdk.ReportCurrentVisitorsParams{
SiteID: sdk.F[string]("CDBUGS"),
Detailed: sdk.F[bool](false),
})
if err != nil {
panic(err)
}
type SiteListParams ¶
type SiteListParams struct {
// A cursor for use in pagination, working in the opposite direction to
// `starting_after`. `ending_before` is an object ID that defines your place in the
// list.
EndingBefore param.Field[string] `query:"ending_before"`
// A limit on the number of objects to be returned, between 1 and 100.
Limit param.Field[int64] `query:"limit"`
// A cursor for use in pagination. `starting_after` is an object ID that defines
// your place in the list. For example, if you make a list request and receive 10
// objects ending with `obj_foo`, your subsequent call can include
// `starting_after=obj_foo` to fetch the next page.
StartingAfter param.Field[string] `query:"starting_after"`
}
func (SiteListParams) URLQuery ¶
func (r SiteListParams) URLQuery() (v url.Values)
URLQuery serializes SiteListParams's query parameters as `url.Values`.
type SiteNewParams ¶
type SiteNewParams struct {
// The name of the website. Any string (up to 255 characters) is acceptable, and it
// doesn't have to match the website URL. Example: `Daffy's Website`
Name param.Field[string] `json:"name" api:"required"`
// Set to `true` to allow this site to track multiple domains.
MultiDomain param.Field[bool] `json:"multi_domain"`
// How multi-domain data is grouped. Supported values are `combined` (report all
// domains together) or `separate` (report each domain individually).
//
// **Required if multi_domain is true.**
MultiDomainOption param.Field[SiteNewParamsMultiDomainOption] `json:"multi_domain_option"`
// site with (up to 255 characters).
//
// **Required if sharing is private.**
SharePassword param.Field[string] `json:"share_password"`
// The sharing configuration. Supported values are `none`, `private` or `public`.
Sharing param.Field[SiteNewParamsSharing] `json:"sharing"`
// The site's reporting timezone as a [TZ database
// name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (e.g.
// `America/New_York`). If omitted, the site inherits your account's default
// timezone.
Timezone param.Field[string] `json:"timezone"`
}
func (SiteNewParams) MarshalJSON ¶
func (r SiteNewParams) MarshalJSON() (data []byte, err error)
type SiteNewParamsMultiDomainOption ¶
type SiteNewParamsMultiDomainOption string
const ( SiteNewParamsMultiDomainOptionCombined SiteNewParamsMultiDomainOption = "combined" SiteNewParamsMultiDomainOptionSeparate SiteNewParamsMultiDomainOption = "separate" )
func (SiteNewParamsMultiDomainOption) IsKnown ¶
func (r SiteNewParamsMultiDomainOption) IsKnown() bool
type SiteNewParamsSharing ¶
type SiteNewParamsSharing string
const ( SiteNewParamsSharingNone SiteNewParamsSharing = "none" SiteNewParamsSharingPrivate SiteNewParamsSharing = "private" SiteNewParamsSharingPublic SiteNewParamsSharing = "public" )
func (SiteNewParamsSharing) IsKnown ¶
func (r SiteNewParamsSharing) IsKnown() bool
type SiteService ¶
type SiteService struct {
Options []option.RequestOption
}
SiteService contains methods and other services that help with interacting with the API. You should not instantiate this service directly, and instead use the NewSiteService method instead.
func NewSiteService ¶
func NewSiteService(opts ...option.RequestOption) (r *SiteService)
NewSiteService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*SiteService) Delete ¶
func (r *SiteService) Delete(ctx context.Context, siteID string, opts ...option.RequestOption) (err error)
Delete a site. Careful: you can't undo this, and neither can we.
**Permissions:** Requires full account access (`*`).
**Returns:** Returns a deleted object on success. Otherwise, this call returns an error.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Sites.Delete(context.Background(), "CDBUGS")
if err != nil {
panic(err)
}
func (*SiteService) Get ¶
func (r *SiteService) Get(ctx context.Context, siteID string, opts ...option.RequestOption) (err error)
Return a single site.
**Permissions:** Requires read access to the site (`all-sites-readonly`, `read:{site_id}` or `manage:{site_id}`).
**Returns:** A site object.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Sites.Get(context.Background(), "CDBUGS")
if err != nil {
panic(err)
}
func (*SiteService) List ¶
func (r *SiteService) List(ctx context.Context, query SiteListParams, opts ...option.RequestOption) (err error)
Return a list of all sites this API key owns. Sites are sorted by `created_at` ascending to allow you to paginate with ease.
**Permissions:** Requires read access to all sites (`all-sites-readonly`) or full account access.
**Returns:** A list of site objects.
Parameters:
ctx: Context for the request. query: SiteListParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Sites.List(context.Background(), sdk.SiteListParams{
Limit: sdk.F[int64](10),
})
if err != nil {
panic(err)
}
func (*SiteService) New ¶
func (r *SiteService) New(ctx context.Context, body SiteNewParams, opts ...option.RequestOption) (err error)
Create a site.
**Permissions:** Requires full account access (`*`).
**Returns:** A site object.
Parameters:
ctx: Context for the request. body: SiteNewParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Sites.New(context.Background(), sdk.SiteNewParams{
Name: sdk.F[string]("Bugs Bunny Portfolio"),
})
if err != nil {
panic(err)
}
func (*SiteService) Update ¶
func (r *SiteService) Update(ctx context.Context, siteID string, body SiteUpdateParams, opts ...option.RequestOption) (err error)
Update a site. Send only the fields you want to change.
**Permissions:** Requires write access to the site (`manage:{site_id}`).
**Returns:** A site object.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. body: SiteUpdateParams request parameters. opts: Options to apply to this request.
Returns:
error: Successful response
Example:
err := client.Sites.Update(context.Background(), "CDBUGS", sdk.SiteUpdateParams{})
if err != nil {
panic(err)
}
func (*SiteService) Wipe
deprecated
func (r *SiteService) Wipe(ctx context.Context, siteID string, opts ...option.RequestOption) (err error)
Previously wiped all pageviews and event completions from a website. This endpoint is no longer available.
Parameters:
ctx: Context for the request. siteID: The ID of the site. This is the same string you use in your tracking code. opts: Options to apply to this request.
Returns:
error: This endpoint has been retired and now returns `410 Gone`. It is no longer possible to wipe a site's data via the API.
Example:
err := client.Sites.Wipe(context.Background(), "CDBUGS")
if err != nil {
panic(err)
}
Deprecated: this method is deprecated.
type SiteUpdateParams ¶
type SiteUpdateParams struct {
// Set to `true` to allow this site to track multiple domains.
MultiDomain param.Field[bool] `json:"multi_domain"`
// How multi-domain data is grouped: `combined` or `separate`.
//
// **Required if multi_domain is true.**
MultiDomainOption param.Field[SiteUpdateParamsMultiDomainOption] `json:"multi_domain_option"`
// The name of the website (up to 255 characters).
Name param.Field[string] `json:"name"`
// site with (up to 255 characters).
//
// **Required if sharing is private.**
SharePassword param.Field[string] `json:"share_password"`
// The sharing configuration. Supported values are `none`, `private` or `public`.
Sharing param.Field[SiteUpdateParamsSharing] `json:"sharing"`
// The site's reporting timezone as a [TZ database
// name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (e.g.
// `America/New_York`). Reporting for this site will use this timezone.
Timezone param.Field[string] `json:"timezone"`
}
func (SiteUpdateParams) MarshalJSON ¶
func (r SiteUpdateParams) MarshalJSON() (data []byte, err error)
type SiteUpdateParamsMultiDomainOption ¶
type SiteUpdateParamsMultiDomainOption string
const ( SiteUpdateParamsMultiDomainOptionCombined SiteUpdateParamsMultiDomainOption = "combined" SiteUpdateParamsMultiDomainOptionSeparate SiteUpdateParamsMultiDomainOption = "separate" )
func (SiteUpdateParamsMultiDomainOption) IsKnown ¶
func (r SiteUpdateParamsMultiDomainOption) IsKnown() bool
type SiteUpdateParamsSharing ¶
type SiteUpdateParamsSharing string
const ( SiteUpdateParamsSharingNone SiteUpdateParamsSharing = "none" SiteUpdateParamsSharingPrivate SiteUpdateParamsSharing = "private" SiteUpdateParamsSharingPublic SiteUpdateParamsSharing = "public" )
func (SiteUpdateParamsSharing) IsKnown ¶
func (r SiteUpdateParamsSharing) IsKnown() bool