ga4

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 19 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"
	// ViewSearchResultsEventType is the event type for view search results
	ViewSearchResultsEventType = "view_search_results"
	// SearchEventType is the event type for searches
	SearchEventType = "search"
	// FormSubmitEventType is the event type for form interactions
	FormSubmitEventType = "form_submit"
	// FormStartEventType is the event type for form starts
	FormStartEventType = "form_start"
	// VideoStartEventType is the event type for video starts
	VideoStartEventType = "video_start"
	// VideoCompleteEventType is the event type for video completes
	VideoCompleteEventType = "video_complete"
	// VideoProgressEventType is the event type for video progress
	VideoProgressEventType = "video_progress"
	// FileDownloadEventType is the event type for file downloads
	FileDownloadEventType = "file_download"
	// PurchaseEventType is the event type for purchases
	PurchaseEventType = "purchase"
	// AddToCartEventType is the event type for add to cart
	AddToCartEventType = "add_to_cart"
)
View Source
const DeviceCategorySmartphone = "smartphone"

DeviceCategorySmartphone is a const value for core.d8a.tech/events/device_category for smartphone devices

Variables

View Source
var ProtocolInterfaces = struct {
	EventMeasurementID schema.Interface

	EventIParamgnoreReferrer   schema.Interface
	EventParamEngagementTimeMs schema.Interface

	// E-commerce columns
	EventEcommercePurchaseRevenue      schema.Interface
	EventEcommercePurchaseRevenueInUSD schema.Interface
	EventEcommerceRefundValue          schema.Interface
	EventEcommerceRefundValueInUSD     schema.Interface
	EventEcommerceShippingValue        schema.Interface
	EventEcommerceShippingValueInUSD   schema.Interface
	EventEcommerceTaxValue             schema.Interface
	EventEcommerceTaxValueInUSD        schema.Interface
	EventEcommerceItemsTotalQuantity   schema.Interface
	EventEcommerceUniqueItems          schema.Interface
	EventItems                         schema.Interface

	// Session columns
	GaSessionID                  schema.Interface
	GaSessionNumber              schema.Interface
	EventGtmDebug                schema.Interface
	EventPageLoadHash            schema.Interface
	EventParams                  schema.Interface
	EventParamAclid              schema.Interface
	EventPrivacyAdsStorage       schema.Interface
	EventPrivacyAnalyticsStorage schema.Interface
	EventParamAnid               schema.Interface

	// Event params
	EventParamAchievementID               schema.Interface
	EventParamAdEventID                   schema.Interface
	EventParamAdUnitCode                  schema.Interface
	EventParamAppVersion                  schema.Interface
	EventParamCampaign                    schema.Interface
	EventParamCampaignContent             schema.Interface
	EventParamCampaignID                  schema.Interface
	EventParamCampaignMedium              schema.Interface
	EventParamCampaignSource              schema.Interface
	EventParamCampaignTerm                schema.Interface
	EventParamCancellationReason          schema.Interface
	EventParamCharacter                   schema.Interface
	EventParamContentDescription          schema.Interface
	EventParamContentGroup                schema.Interface
	EventParamContentID                   schema.Interface
	EventParamContentType                 schema.Interface
	EventParamCoupon                      schema.Interface
	EventParamCreativeName                schema.Interface
	EventParamCreativeSlot                schema.Interface
	EventParamCurrency                    schema.Interface
	EventParamDclid                       schema.Interface
	EventParamDeferredAnalyticsCollection schema.Interface
	EventParamDisqualifiedLeadReason      schema.Interface
	EventParamExposureTime                schema.Interface
	EventParamFatal                       schema.Interface
	EventParamFileExtension               schema.Interface
	EventParamFileName                    schema.Interface
	EventParamFirebaseError               schema.Interface
	EventParamFirebaseErrorValue          schema.Interface
	EventParamFirebasePreviousClass       schema.Interface
	EventParamFirebasePreviousID          schema.Interface
	EventParamFirebasePreviousScreen      schema.Interface
	EventParamFirebaseScreen              schema.Interface
	EventParamFirebaseScreenClass         schema.Interface
	EventParamFirebaseScreenID            schema.Interface
	EventParamFormDestination             schema.Interface
	EventParamFormID                      schema.Interface
	EventParamFormName                    schema.Interface
	EventParamFormSubmitText              schema.Interface
	EventParamFreeTrial                   schema.Interface
	EventParamGaSessionID                 schema.Interface
	EventParamGaSessionNumber             schema.Interface
	EventParamGclid                       schema.Interface
	EventParamGroupID                     schema.Interface
	EventParamIntroductoryPrice           schema.Interface
	EventParamItemListID                  schema.Interface
	EventParamItemListName                schema.Interface
	EventParamItemName                    schema.Interface
	EventParamLabel                       schema.Interface
	EventParamLanguage                    schema.Interface
	EventParamLeadSource                  schema.Interface
	EventParamLeadStatus                  schema.Interface
	EventParamLevel                       schema.Interface
	EventParamLevelName                   schema.Interface
	EventParamLinkClasses                 schema.Interface
	EventParamLinkDomain                  schema.Interface
	EventParamLinkID                      schema.Interface
	EventParamLinkText                    schema.Interface
	EventParamLinkURL                     schema.Interface
	EventParamMessageDeviceTime           schema.Interface
	EventParamMessageID                   schema.Interface
	EventParamMessageName                 schema.Interface
	EventParamMessageTime                 schema.Interface
	EventParamMessageType                 schema.Interface
	EventParamMethod                      schema.Interface
	EventParamOutbound                    schema.Interface
	EventParamPaymentType                 schema.Interface
	EventParamPercentScrolled             schema.Interface
	EventParamPreviousAppVersion          schema.Interface
	EventParamPreviousFirstOpenCount      schema.Interface
	EventParamPreviousGmpAppID            schema.Interface
	EventParamPreviousOSVersion           schema.Interface
	EventParamPrice                       schema.Interface
	EventParamProductID                   schema.Interface
	EventParamPromotionID                 schema.Interface
	EventParamPromotionName               schema.Interface
	EventParamQuantity                    schema.Interface
	EventParamRenewalCount                schema.Interface
	EventParamResetAnalyticsCause         schema.Interface
	EventParamRewardType                  schema.Interface
	EventParamRewardValue                 schema.Interface
	EventParamScore                       schema.Interface
	EventParamScreenResolution            schema.Interface
	EventParamSearchTerm                  schema.Interface
	EventParamShipping                    schema.Interface
	EventParamShippingTier                schema.Interface
	EventParamSrsltid                     schema.Interface
	EventParamSubscription                schema.Interface
	EventParamSuccess                     schema.Interface
	EventParamSystemApp                   schema.Interface
	EventParamSystemAppUpdate             schema.Interface
	EventParamTax                         schema.Interface
	EventParamTopic                       schema.Interface
	EventParamTransactionID               schema.Interface
	EventParamUnconvertLeadReason         schema.Interface
	EventParamUpdatedWithAnalytics        schema.Interface
	EventParamValue                       schema.Interface
	EventParamVideoCurrentTime            schema.Interface
	EventParamVideoDuration               schema.Interface
	EventParamVideoPercent                schema.Interface
	EventParamVideoProvider               schema.Interface
	EventParamVideoTitle                  schema.Interface
	EventParamVideoURL                    schema.Interface
	EventParamVirtualCurrencyName         schema.Interface
	EventParamVisible                     schema.Interface

	// Page navigation columns
	EventNextPageLocation     schema.Interface
	EventPreviousPageLocation schema.Interface
	EventNextPageTitle        schema.Interface
	EventPreviousPageTitle    schema.Interface

	// Session engagement
	SessionIsEngaged     schema.Interface
	SessionReturningUser schema.Interface
	SessionAbandonedCart schema.Interface

	// Item params
	EventParamItemProductID schema.Interface
	EventParamItemPrice     schema.Interface
	EventParamItemQuantity  schema.Interface

	// Source columns extracted from page URL
	EventSourceManualCampaignID      schema.Interface
	EventSourceManualCampaignName    schema.Interface
	EventSourceManualSource          schema.Interface
	EventSourceManualMedium          schema.Interface
	EventSourceManualTerm            schema.Interface
	EventSourceManualContent         schema.Interface
	EventSourceManualSourcePlatform  schema.Interface
	EventSourceManualCreativeFormat  schema.Interface
	EventSourceManualMarketingTactic schema.Interface
	EventSourceGclid                 schema.Interface
	EventSourceDclid                 schema.Interface
	EventSourceSrsltid               schema.Interface

	EventGl schema.Interface

}{}/* 150 elements not displayed */

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

Functions

func ColumnFromRawQueryParamOrDeviceInfo added in v0.5.0

func ColumnFromRawQueryParamOrDeviceInfo(
	interfaceID schema.InterfaceID,
	field *arrow.Field,
	queryParam string,
	deviceInfoFunc func(event *schema.Event, di *devicedetector.DeviceInfo) (any, error),
	options ...columns.EventColumnOptions,
) schema.EventColumn

ColumnFromRawQueryParamOrDeviceInfo creates a new event colum, parsing raw value from query param or alternatively using device info from the user agent

func NewGA4Protocol

func NewGA4Protocol(
	converter currency.Converter,
	psr properties.SettingsRegistry,
) 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],
	options ...columns.EventColumnOptions,
) 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