ga4

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 16 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"
)
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 {
	EventIParamgnoreReferrer   schema.Interface
	EventParamEngagementTimeMs schema.Interface
	// Campaign params
	EventParamCampaign        schema.Interface
	EventParamCampaignID      schema.Interface
	EventParamCampaignSource  schema.Interface
	EventParamCampaignMedium  schema.Interface
	EventParamCampaignContent schema.Interface
	EventParamCampaignTerm    schema.Interface
	// Content params
	EventParamContentGroup       schema.Interface
	EventParamContentID          schema.Interface
	EventParamContentType        schema.Interface
	EventParamContentDescription schema.Interface
	// E-commerce params
	// https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#add_payment_info
	EventParamCoupon        schema.Interface
	EventParamCurrency      schema.Interface
	EventParamShipping      schema.Interface
	EventParamShippingTier  schema.Interface
	EventParamPaymentType   schema.Interface
	EventParamTax           schema.Interface
	EventParamTransactionID schema.Interface
	EventParamValue         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
	EventEcommerceUniqueItems          schema.Interface
	EventEcommerceItemsTotalQuantity   schema.Interface

	// Item list params
	EventParamItemListID   schema.Interface
	EventParamItemListName schema.Interface
	// Creative and promotion params
	EventParamCreativeName  schema.Interface
	EventParamCreativeSlot  schema.Interface
	EventParamPromotionID   schema.Interface
	EventParamPromotionName schema.Interface
	// Link params
	EventParamLinkClasses schema.Interface
	EventParamLinkDomain  schema.Interface
	EventParamLinkID      schema.Interface
	EventParamLinkText    schema.Interface
	EventParamLinkURL     schema.Interface
	EventParamOutbound    schema.Interface
	// Ad related params (ad_exposure, ad_query, ad_impression, ad_reward)
	// https://support.google.com/analytics/answer/9234069?hl=en
	EventParamAdEventID    schema.Interface
	EventParamExposureTime schema.Interface
	EventParamAdUnitCode   schema.Interface
	EventParamRewardType   schema.Interface
	EventParamRewardValue  schema.Interface
	// Video params
	EventParamVideoCurrentTime schema.Interface
	EventParamVideoDuration    schema.Interface
	EventParamVideoPercent     schema.Interface
	EventParamVideoProvider    schema.Interface
	EventParamVideoTitle       schema.Interface
	EventParamVideoURL         schema.Interface
	// App params
	// https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtag#add_payment_info
	EventParamMethod             schema.Interface // used in login, share, sign_up
	EventParamCancellationReason schema.Interface // used in app_store_subscription_cancel
	EventParamFatal              schema.Interface // used in app_exception

	// Firebase params
	EventParamFirebaseError          schema.Interface
	EventParamFirebaseErrorValue     schema.Interface
	EventParamFirebaseScreen         schema.Interface
	EventParamFirebaseScreenClass    schema.Interface
	EventParamFirebaseScreenID       schema.Interface
	EventParamFirebasePreviousScreen schema.Interface
	EventParamFirebasePreviousClass  schema.Interface
	EventParamFirebasePreviousID     schema.Interface
	// Subscription params
	EventParamFreeTrial         schema.Interface // used in in_app_purchase
	EventParamSubscription      schema.Interface // used in in_app_purchase
	EventParamProductID         schema.Interface // product_id
	EventParamPrice             schema.Interface // price
	EventParamQuantity          schema.Interface // quantity
	EventParamIntroductoryPrice schema.Interface // used in in_app_purchase
	EventParamRenewalCount      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)
	EventParamMessageDeviceTime schema.Interface
	EventParamMessageID         schema.Interface
	EventParamMessageName       schema.Interface

	// used in notification_(foreground|open|dismiss|receive)
	EventParamMessageTime schema.Interface
	EventParamMessageType schema.Interface
	EventParamTopic       schema.Interface
	EventParamLabel       schema.Interface

	// App params - automatically collected with app events
	// https://support.google.com/analytics/answer/9234069?hl=en
	EventParamAppVersion             schema.Interface // app_version - used in app events
	EventParamPreviousAppVersion     schema.Interface // previous_app_version - used in app events
	EventParamPreviousFirstOpenCount schema.Interface // previous_first_open_count - used in app events
	EventParamPreviousOSVersion      schema.Interface // previous_os_version - used in app events
	EventParamUpdatedWithAnalytics   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
	EventParamAchievementID       schema.Interface // achievement_id - used in unlock_achievement event
	EventParamCharacter           schema.Interface // character - used in level_up and other gaming events
	EventParamLevel               schema.Interface // level - used in level_up event
	EventParamLevelName           schema.Interface // level_name - used in level_up event
	EventParamScore               schema.Interface // score - used in gaming events
	EventParamVirtualCurrencyName schema.Interface // virtual_currency_name - earn_virtual_currency, spend_virtual_currency
	EventParamItemName            schema.Interface // item_name - used in spend_virtual_currency
	EventParamSuccess             schema.Interface // success - used in various gaming events
	// System params - automatically collected with app events
	// https://support.google.com/analytics/answer/9234069?hl=en
	EventParamVisible                     schema.Interface // visible - used in app events
	EventParamScreenResolution            schema.Interface // screen_resolution - used in app events
	EventParamSystemApp                   schema.Interface // system_app - used in app events
	EventParamSystemAppUpdate             schema.Interface // system_app_update - used in app events
	EventParamDeferredAnalyticsCollection schema.Interface // deferred_analytics_collection - used in app events
	EventParamResetAnalyticsCause         schema.Interface // reset_analytics_cause - used in app events
	EventParamPreviousGmpAppID            schema.Interface // previous_gmp_app_id - used in app events
	// Form and file params - used in form and file events
	EventParamFileExtension   schema.Interface // file_extension - used in file events
	EventParamFileName        schema.Interface // file_name - used in file events
	EventParamFormDestination schema.Interface // form_destination - used in form events
	EventParamFormID          schema.Interface // form_id - used in form events
	EventParamFormName        schema.Interface // form_name - used in form events
	EventParamFormSubmitText  schema.Interface // form_submit_text - used in form events

	// Engagement params
	// group_id - used in join_group event
	EventParamGroupID schema.Interface
	// language - automatically collected with web events (page_view, etc.)
	EventParamLanguage schema.Interface
	// percent_scrolled - used in scroll event (enhanced measurement)
	EventParamPercentScrolled schema.Interface
	// search_term - used in view_search_results event (enhanced measurement)
	EventParamSearchTerm schema.Interface
	// Lead params
	// unconvert_lead_reason - used in custom lead tracking events
	EventParamUnconvertLeadReason schema.Interface
	// disqualified_lead_reason - used in custom lead tracking events
	EventParamDisqualifiedLeadReason schema.Interface
	// lead_source - used in custom lead tracking events
	EventParamLeadSource schema.Interface
	// lead_status - used in custom lead tracking events
	EventParamLeadStatus schema.Interface
	// Session params
	SessionEngagement             schema.Interface
	SessionParamParamsGaSessionID schema.Interface
	SessionParamsGaSessionNumber  schema.Interface
	SessionParamNumber            schema.Interface

	// Item params
	EventItems              schema.Interface
	EventParamItemProductID schema.Interface
	EventParamItemPrice     schema.Interface
	EventParamItemQuantity  schema.Interface
	// Page URL params
	EventGtmDebug schema.Interface
	EventGl       schema.Interface

	// **lid params
	EventParamGclid   schema.Interface
	EventParamDclid   schema.Interface
	EventParamSrsltid schema.Interface
	EventParamAclid   schema.Interface
	EventParamAnid    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

	// _p parameter (page load hash, usually contains a timestamp in milliseconds. If not - returns nil)
	EventPageLoadHash schema.Interface

	// Privacy
	EventPrivacyAnalyticsStorage schema.Interface
	EventPrivacyAdsStorage       schema.Interface

}{}/* 141 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),
) 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) 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