sdk

package
v4.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendGA4Event added in v4.3.5

func SendGA4Event(name string, params map[string]interface{})

Types

type Event added in v4.3.5

type Event struct {
	// Required. The name for the event.
	Name string `json:"name"`
	// Optional. The parameters for the event.
	// engagement_time_msec/session_id
	Params map[string]interface{} `json:"params,omitempty"`
}

type GA4Client added in v4.3.5

type GA4Client struct {
	// contains filtered or unexported fields
}

func NewGA4Client added in v4.3.5

func NewGA4Client(measurementID, apiSecret string, debug ...bool) *GA4Client

NewGA4Client creates a new GA4Client object with the measurementID and apiSecret.

func (*GA4Client) SendEvent added in v4.3.5

func (g *GA4Client) SendEvent(event Event) error

SendEvent sends one event to Google Analytics

type Payload added in v4.3.5

type Payload struct {
	// Required. Uniquely identifies a user instance of a web client
	ClientID string `json:"client_id"`
	// Optional. A unique identifier for a user
	UserID string `json:"user_id,omitempty"`
	// Optional. A Unix timestamp (in microseconds) for the time to associate with the event.
	// This should only be set to record events that happened in the past.
	// This value can be overridden via user_property or event timestamps.
	// Events can be backdated up to 3 calendar days based on the property's timezone.
	TimestampMicros int64 `json:"timestamp_micros,omitempty"`
	// Optional. The user properties for the measurement.
	UserProperties map[string]string `json:"user_properties,omitempty"`
	// Optional. Set to true to indicate these events should not be used for personalized ads.
	NonPersonalizedAds bool `json:"non_personalized_ads,omitempty"`
	// Required. An array of event items. Up to 25 events can be sent per request.
	Events []Event `json:"events"`
}

payload docs reference: https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference?client_type=gtag

type ValidationCode added in v4.3.5

type ValidationCode string
const (
	VALUE_INVALID         ValidationCode = "VALUE_INVALID"         // The value provided for a fieldPath was invalid.
	VALUE_REQUIRED        ValidationCode = "VALUE_REQUIRED"        // A required value for a fieldPath was not provided.
	NAME_INVALID          ValidationCode = "NAME_INVALID"          // The name provided was invalid.
	NAME_RESERVED         ValidationCode = "NAME_RESERVED"         // The name provided was one of the reserved names.
	VALUE_OUT_OF_BOUNDS   ValidationCode = "VALUE_OUT_OF_BOUNDS"   // The value provided was too large.
	EXCEEDED_MAX_ENTITIES ValidationCode = "EXCEEDED_MAX_ENTITIES" // There were too many parameters in the request.
	NAME_DUPLICATED       ValidationCode = "NAME_DUPLICATED"       // The same name was provided more than once in the request.
)

type ValidationMessage added in v4.3.5

type ValidationMessage struct {
	FieldPath      string         `json:"fieldPath"`      // The path to the field that was invalid.
	Description    string         `json:"description"`    // A description of the error.
	ValidationCode ValidationCode `json:"validationCode"` // A ValidationCode that corresponds to the error.
}

type ValidationResponse added in v4.3.5

type ValidationResponse struct {
	ValidationMessages []ValidationMessage `json:"validationMessages"` // An array of validation messages.
}

validation docs reference: https://developers.google.com/analytics/devguides/collection/protocol/ga4/validating-events?client_type=gtag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL