ga4

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ga4 provides GA4 protocol specific column definitions.

Package ga4 provides Google Analytics 4 protocol support.

Package ga4 provides implementation of the ga4 protocol, eventually supporting gtag, mp and other sub-protocols

Index

Constants

View Source
const (
	// PageViewEventType is the event type for page views
	PageViewEventType = "page_view"
	// ScrollEventType is the event type for scrolls
	ScrollEventType = "scroll"
	// ClickEventType is the event type for clicks
	ClickEventType = "click"
	// RefundEventType is the event type for refunds
	RefundEventType = "refund"
)

Variables

View Source
var ProtocolInterfaces = struct {
	EventIgnoreReferrer   schema.Interface
	EventEngagementTimeMs schema.Interface
	// Campaign params
	EventCampaign        schema.Interface
	EventCampaignID      schema.Interface
	EventCampaignSource  schema.Interface
	EventCampaignMedium  schema.Interface
	EventCampaignContent schema.Interface
	EventCampaignTerm    schema.Interface
	// Content params
	EventContentGroup       schema.Interface
	EventContentID          schema.Interface
	EventContentType        schema.Interface
	EventContentDescription schema.Interface
	// E-commerce params
	// https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#add_payment_info
	EventCoupon               schema.Interface
	EventCurrency             schema.Interface
	EventShipping             schema.Interface
	EventShippingTier         schema.Interface
	EventPaymentType          schema.Interface
	EventTax                  schema.Interface
	EventTransactionID        schema.Interface
	EventValue                schema.Interface
	EventPurchaseRevenue      schema.Interface
	EventPurchaseRevenueInUSD schema.Interface
	EventRefundValue          schema.Interface
	EventRefundValueInUSD     schema.Interface
	EventShippingValue        schema.Interface
	EventShippingValueInUSD   schema.Interface
	EventTaxValueInUSD        schema.Interface
	EventUniqueItems          schema.Interface

	// Item list params
	EventItemListID   schema.Interface
	EventItemListName schema.Interface
	// Creative and promotion params
	EventCreativeName  schema.Interface
	EventCreativeSlot  schema.Interface
	EventPromotionID   schema.Interface
	EventPromotionName schema.Interface
	// Link params
	EventLinkClasses schema.Interface
	EventLinkDomain  schema.Interface
	EventLinkID      schema.Interface
	EventLinkText    schema.Interface
	EventLinkURL     schema.Interface
	EventOutbound    schema.Interface
	// Ad related params (ad_exposure, ad_query, ad_impression, ad_reward)
	// https://support.google.com/analytics/answer/9234069?hl=en
	EventAdEventID    schema.Interface
	EventExposureTime schema.Interface
	EventAdUnitCode   schema.Interface
	EventRewardType   schema.Interface
	EventRewardValue  schema.Interface
	// Video params
	EventVideoCurrentTime schema.Interface
	EventVideoDuration    schema.Interface
	EventVideoPercent     schema.Interface
	EventVideoProvider    schema.Interface
	EventVideoTitle       schema.Interface
	EventVideoURL         schema.Interface
	// App params
	// https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#add_payment_info
	EventMethod             schema.Interface // used in login, share, sign_up
	EventCancellationReason schema.Interface // used in app_store_subscription_cancel
	EventFatal              schema.Interface // used in app_exception

	// Firebase params
	EventFirebaseError          schema.Interface
	EventFirebaseErrorValue     schema.Interface
	EventFirebaseScreen         schema.Interface
	EventFirebaseScreenClass    schema.Interface
	EventFirebaseScreenID       schema.Interface
	EventFirebasePreviousScreen schema.Interface
	EventFirebasePreviousClass  schema.Interface
	EventFirebasePreviousID     schema.Interface
	// Subscription params
	EventFreeTrial         schema.Interface // used in in_app_purchase
	EventSubscription      schema.Interface // used in in_app_purchase
	EventIntroductoryPrice schema.Interface // used in in_app_purchase
	EventRenewalCount      schema.Interface // used in app_store_subscription_renew
	// Message params
	// all used in firebase_in_app_message_(action|dismiss|impression), fiam_(action|dismiss|impression)
	// notification_(foreground|open|dismiss|receive)
	EventMessageDeviceTime schema.Interface
	EventMessageID         schema.Interface
	EventMessageName       schema.Interface

	// used in notification_(foreground|open|dismiss|receive)
	EventMessageTime schema.Interface
	EventMessageType schema.Interface
	EventTopic       schema.Interface
	EventLabel       schema.Interface

	// App params - automatically collected with app events
	// https://support.google.com/analytics/answer/9234069?hl=en
	EventAppVersion             schema.Interface // app_version - used in app events
	EventPreviousAppVersion     schema.Interface // previous_app_version - used in app events
	EventPreviousFirstOpenCount schema.Interface // previous_first_open_count - used in app events
	EventPreviousOSVersion      schema.Interface // previous_os_version - used in app events
	EventUpdatedWithAnalytics   schema.Interface // updated_with_analytics - used in app events
	// Gaming params - used in gaming events
	// https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag
	EventAchievementID       schema.Interface // achievement_id - used in unlock_achievement event
	EventCharacter           schema.Interface // character - used in level_up and other gaming events
	EventLevel               schema.Interface // level - used in level_up event
	EventLevelName           schema.Interface // level_name - used in level_up event
	EventScore               schema.Interface // score - used in gaming events
	EventVirtualCurrencyName schema.Interface // virtual_currency_name - earn_virtual_currency, spend_virtual_currency
	EventItemName            schema.Interface // item_name - used in spend_virtual_currency
	EventSuccess             schema.Interface // success - used in various gaming events
	// System params - automatically collected with app events
	// https://support.google.com/analytics/answer/9234069?hl=en
	EventVisible                     schema.Interface // visible - used in app events
	EventScreenResolution            schema.Interface // screen_resolution - used in app events
	EventSystemApp                   schema.Interface // system_app - used in app events
	EventSystemAppUpdate             schema.Interface // system_app_update - used in app events
	EventDeferredAnalyticsCollection schema.Interface // deferred_analytics_collection - used in app events
	EventResetAnalyticsCause         schema.Interface // reset_analytics_cause - used in app events
	EventPreviousGmpAppID            schema.Interface // previous_gmp_app_id - used in app events
	// Form and file params - used in form and file events
	EventFileExtension   schema.Interface // file_extension - used in file events
	EventFileName        schema.Interface // file_name - used in file events
	EventFormDestination schema.Interface // form_destination - used in form events
	EventFormID          schema.Interface // form_id - used in form events
	EventFormName        schema.Interface // form_name - used in form events
	EventFormSubmitText  schema.Interface // form_submit_text - used in form events

	// Engagement params
	// group_id - used in join_group event
	EventGroupID schema.Interface
	// language - automatically collected with web events (page_view, etc.)
	EventLanguage schema.Interface
	// percent_scrolled - used in scroll event (enhanced measurement)
	EventPercentScrolled schema.Interface
	// search_term - used in view_search_results event (enhanced measurement)
	EventSearchTerm schema.Interface
	// Lead params
	// unconvert_lead_reason - used in custom lead tracking events
	EventUnconvertLeadReason schema.Interface
	// disqualified_lead_reason - used in custom lead tracking events
	EventDisqualifiedLeadReason schema.Interface
	// lead_source - used in custom lead tracking events
	EventLeadSource schema.Interface
	// lead_status - used in custom lead tracking events
	EventLeadStatus schema.Interface
	// Session params
	SessionEngagement            schema.Interface
	SessionParamsGaSessionID     schema.Interface
	SessionParamsGaSessionNumber schema.Interface
	SessionNumber                schema.Interface
	// Item params
	EventItems    schema.Interface
	ItemName      schema.Interface
	ItemProductID schema.Interface
	ItemPrice     schema.Interface
	ItemQuantity  schema.Interface

}{}/* 115 elements not displayed */

ProtocolInterfaces are the columns that are specific to the ga4 protocol.

Functions

func NewGA4Protocol

func NewGA4Protocol(converter currency.Converter) protocol.Protocol

NewGA4Protocol creates a new instance of the GA4 protocol handler.

func NewItemsBasedEventColumn added in v0.2.0

func NewItemsBasedEventColumn[T int64 | float64](
	interfaceID schema.InterfaceID,
	interfaceField *arrow.Field,
	valueFunc ItemValueFunc[T],
) schema.EventColumn

NewItemsBasedEventColumn creates an event column that aggregates values across items by applying the provided ItemValueFunc to each item and summing.

Types

type ItemValueFunc added in v0.2.0

type ItemValueFunc[T int64 | float64] func(event *schema.Event, item map[string]any) (T, error)

ItemValueFunc computes a numeric value for a single item in an event. It is used to aggregate values across all items of the event.

Jump to

Keyboard shortcuts

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