Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(values url.Values, target any) error
- func DecodeMapValue(k string, v []string, data Data) (bool, error)
- func DecodeObjectValue(s string) (map[string]any, error)
- func DecodeQuery(input string, tarteg any) error
- func DecodeRegexValue(k string, v []string, r *regexp.Regexp, data Data, key string) (bool, error)
- func DecodeRequest(r http.Request, target any) error
- func Encode(payload *Payload) (url.Values, io.Reader, error)
- func EncodeObjectValue(s map[string]any) string
- func EncodeValues(values url.Values) string
- func Get[T any](v *T) T
- func GetDefault[T any](v *T, fallback T) T
- func Set[T any](v T) *T
- type Campaign
- type ClientHints
- type Consent
- type Data
- type ECommerce
- type Item
- type Payload
- type SST
Constants ¶
View Source
const (
ParameterItem = "pr"
)
Variables ¶
View Source
var (
RegexProduct = regexp.MustCompile(`pr([1-9]|[1-9][0-9]|1[0-9]{2}|200)`)
)
Functions ¶
func DecodeObjectValue ¶
DecodeObjectValue e.g. `idSKU_123456` = map["id"]="SKU_123456"
func DecodeQuery ¶
func DecodeRegexValue ¶
DecodeRegexValue e.g. `pr1=idSKU_123456` = map["pr"][]map["id"]="SKU_123456"
func EncodeObjectValue ¶
EncodeObjectValue e.g. `idSKU_123456` = map["id"]="SKU_123456"
func EncodeValues ¶
EncodeValues NOTE: `richsstsse` seems to be last parameter in the query to let's ensure it stays that way
func GetDefault ¶
func GetDefault[T any](v *T, fallback T) T
Types ¶
type Campaign ¶
type Campaign struct { // Campaign Medium ( utm_medium ), this will override the current values read from the url // Example: cpc CampaignMedium *string `json:"campaign_medium,omitempty" gtag:"cm,omitempty"` // Campaign Source ( utm_source ), this will override the current values read from the url // Example: google CampaignSource *string `json:"campaign_source,omitempty" gtag:"cs,omitempty"` // Campaign Name ( utm_campaign ), this will override the current values read from the url // Example: cpc CampaignName *string `json:"campaign_name,omitempty" gtag:"cn,omitempty"` // Campaign Content ( utm_content ), this will override the current values read from the url // Example: big banner CampaignContent *string `json:"campaign_content,omitempty" gtag:"cc,omitempty"` // Campaign Term ( utm_term ), this will override the current values read from the url // Example: summer CampaignTerm *string `json:"campaign_term,omitempty" gtag:"ck,omitempty"` // Campaign Creative Format ( utm_creative_format ), this will override the current values read from the url // Example: native CampaignCreativeFormat *string `json:"campaign_creative_format,omitempty" gtag:"ccf,omitempty"` // Campaign Marketing Tactic ( utm_marketing_tactic ), this will override the current values read from the url // Example: prospecting CampaignMarketingTactic *string `json:"campaign_marketing_tactic,omitempty" gtag:"cmt,omitempty"` }
type ClientHints ¶
type ClientHints struct { // Is a random hash generated on the page load. // Examole: 456193680 // RandomPageLoadHash *string `json:"random_page_load_hash,omitempty" gtag:"_p,omitempty"` // Browser screen resolution in format width x height // Example: 2560x1440 ScreenResolution *string `json:"screen_resolution,omitempty" gtag:"sr,omitempty"` // Browser active locale. // Example: es-es UserLanguage *string `json:"user_language,omitempty" gtag:"ul,omitempty"` // Example: x86 UserAgentArchitecture *string `json:"user_agent_architecture,omitempty" gtag:"uaa,omitempty"` // The "bitness" of the user-agent's underlying CPU architecture. This is the size in bits of an integer or memory address—typically 64 or 32 bits. // Example: 32 | 64 UserAgentBitness *string `json:"user_agent_bitness,omitempty" gtag:"uab,omitempty"` // The brand and full version information for each brand associated with the browser, in a comma-separated list // Example: Google Chrome;105.0.5195.127|Not)A;Brand;8.0.0.0|Chromium;105.0.5195.127 UserAgentFullVersionList *string `json:"user_agent_full_version_list,omitempty" gtag:"uafvl,omitempty"` // Indicates whether the browser is on a mobile device // Example: 1 UserAgentMobile *string `json:"user_agent_mobile,omitempty" gtag:"uamb,omitempty"` // The device model on which the browser is running. Will likely be empty for desktop browsers // Example: Nexus 6 UserAgentModel *string `json:"user_agent_model,omitempty" gtag:"uam,omitempty"` // The platform or operating system on which the user agent is running // Example: Chromium OS | macOS | Android | iOS UserAgentPlatform *string `json:"user_agent_platform,omitempty" gtag:"uap,omitempty"` // The version of the operating system on which the user agent is running // Example: 14.0.0 UserAgentPlatformVersion *string `json:"user_agent_platform_version,omitempty" gtag:"uapv,omitempty"` // Whatever Windows On Windows 64 Bit is supported. Used by "WoW64-ness" sites. ( running 32bits app on 64bits windows) // Example: 1 UserAgentWOW64 *string `json:"user_agent_wow_64,omitempty" gtag:"uaw,omitempty"` // Added to report the current country for the user under some circumstanced. To be documented. // Example: ES UserCountry *string `json:"user_country,omitempty" gtag:"_uc,omitempty"` // Example: DE-BY UserRegion *string `json:"user_region,omitempty" gtag:"ur,omitempty"` }
type Consent ¶
type Consent struct { // Current Google Consent Status. Format 'G1'+'AdsStorageBoolStatus'`+'AnalyticsStorageBoolStatus' // Example: G101 GoogleConsentStatus *string `json:"google_consent_status,omitempty" gtag:"gcs,omitempty"` // Will be added with the value "1" if the Google Consent has just been updated (wait_for_update setting on GTAG) // Example: 1 GoogleConsentUpdate *string `json:"google_consent_update,omitempty" gtag:"gcu,omitempty"` // Documented values, 1 or 2, no more info on the meaning // Example: 2 GoogleConsentUpdateType *string `json:"google_consent_update_type,omitempty" gtag:"gcut,omitempty"` // Will be added with the value "1" if the Google Consent had a default value before getting an update // Example: G111 GoogleConsentDefault *string `json:"google_consent_default,omitempty" gtag:"gcd,omitempty"` }
See https://developers.google.com/tag-platform/security/concepts/consent-mode
func (Consent) AdPersonalization ¶ added in v0.6.0
func (Consent) AdUserData ¶ added in v0.6.0
func (Consent) AnalyticsStorage ¶ added in v0.4.0
type ECommerce ¶
type ECommerce struct { // Currency Code. ISO 4217 // Example: JPY Currency *iso4217.Currency `json:"currency,omitempty" gtag:"cu,omitempty"` // Example: Items []*Item `json:"items,omitempty" gtag:"pr,omitempty"` // Promotion Impression/Click Tracking. Promotion Id // Example: summer-offer PromotionID *string `json:"promotion_id,omitempty" gtag:"pi,omitempty"` // Promotion Impression/Click Tracking. Promotion Name // Example: summer-offer PromotionName *string `json:"promotion_name,omitempty" gtag:"pn,omitempty"` // Promotion Impression/Click Tracking. Creative Name // Example: red-car // CreativeName *string `json:"//,omitempty" gtag:"cn,omitempty"` // Promotion Impression/Click Tracking. Promotion Slot / Position // Example: slide-3 // CreativeSlot *string `json:"//,omitempty" gtag:"cs,omitempty"` // Google Place ID: Refer to: https://developers.google.com/maps/documentation/places/web-service/place-id . Seems to be inherited from Firebase, not sure about the current use on GA4 // Example: ChIJiyj437sx3YAR9kUWC8QkLzQ LocationID *string `json:"location_id,omitempty" gtag:"lo,omitempty"` // If the current event is set as a conversion on the admin interacted the evfent will have this value present // Example: 1 IsConversion *string `json:"is_conversion,omitempty" gtag:"_c,omitempty"` }
type Item ¶
type Item struct { // Example: Foo Marketplace Affiliation *string `json:"affiliation,omitempty" gtag:"af,omitempty"` // Example: 50%OFF Coupon *string `json:"coupon,omitempty" gtag:"cp,omitempty"` // The name of the promotional creative. // Example: summer_banner2 CreativeName *string `json:"creative_name,omitempty" gtag:"cn,omitempty"` // The name of the promotional creative slot associated with the item. // Example: featured_app_1 CreativeSlot *string `json:"creative_slot,omitempty" gtag:"cs,omitempty"` // Example: 10.00 Discount *string `json:"discount,omitempty" gtag:"ds,omitempty"` // Example: Google ItemBrand *string `json:"item_brand,omitempty" gtag:"br,omitempty"` // Example: men ItemCategory *string `json:"item_category,omitempty" gtag:"ca,omitempty"` // Example: t-shirts ItemCategory2 *string `json:"item_category2,omitempty" gtag:"c2,omitempty"` // Example: men ItemCategory3 *string `json:"item_category3,omitempty" gtag:"c3,omitempty"` // Example: men ItemCategory4 *string `json:"item_category4,omitempty" gtag:"c4,omitempty"` // Example: men ItemCategory5 *string `json:"item_category5,omitempty" gtag:"c5,omitempty"` // Example: 12345 ItemID *string `json:"item_id,omitempty" gtag:"id,omitempty"` // Example: id-mens-123 ItemListID *string `json:"item_list_id,omitempty" gtag:"li,omitempty"` // Example: cross-selling: mens ItemListName *string `json:"item_list_name,omitempty" gtag:"ln,omitempty"` // Example: Stan and Friends Tee ItemName *string `json:"item_name,omitempty" gtag:"nm,omitempty"` // Example: Yellow ItemVariant *string `json:"item_variant,omitempty" gtag:"va,omitempty"` // Example: 10 FIXME ItemListPosition *string `json:"item_list_position,omitempty" gtag:"lp,omitempty"` // Example: ChIJIQBpAG2ahYAR_6128GcTUEo LocationID *string `json:"location_id,omitempty" gtag:"lo,omitempty"` // Example: 123.45 Price *string `json:"price,omitempty" gtag:"pr,omitempty"` // The ID of the promotion associated with the item. // Example: P_12345 PromotionID *string `json:"promotion_id,omitempty" gtag:"pi,omitempty"` // The name of the promotion associated with the item. // Example: Summer Sale PromotionName *string `json:"promotion_name,omitempty" gtag:"pn,omitempty"` // Example: 1 Quantity *string `json:"quantity,omitempty" gtag:"qt,omitempty"` }
type Payload ¶
type Payload struct { Consent `json:"consent" gtag:",inline,squash"` Campaign `json:"campaign" gtag:",inline,squash"` ECommerce `json:"ecommerce" gtag:",inline,squash"` ClientHints `json:"client_hints" gtag:",inline,squash"` // Defines que current protocol version being used. // Example: 2 ProtocolVersion *string `json:"protocol_version,omitempty" gtag:"v,omitempty"` // Current Stream ID / Measurement ID // Example: G-THYNGSTER TrackingID *string `json:"tracking_id,omitempty" gtag:"tid,omitempty"` // If the current hit is coming was generated from GTM, it will contain a hash of current GTM/GTAG config // Example: 2oear0 GTMHashInfo *string `json:"gtmhash_info,omitempty" gtag:"gtm,omitempty"` // Current Document Hostname // Exampple: www.analytics-debugger.com // DocumentHostname *string `json:"document_hostname,omitempty" gtag:"dh,omitempty"` // Google Analytics Client Id // Example: 281344611.1635634925 ClientID *string `json:"client_id,omitempty" gtag:"cid,omitempty"` // Current hits counter for the current page load // Example: 1 // HitCounter *string `json:"hit_counter,omitempty" gtag:"_s,omitempty"` // This is supposed to be to enrich the GA4 hits to send data to SGTM, at this point is always set as an empty value... Richsstsse *string `json:"richsstsse,omitempty" gtag:"richsstsse,omitempty"` // Actual page's Pathname. It does not include the hostname, quertyString or Fragment // Example: /hire-me DocumentLocation *string `json:"document_location,omitempty" gtag:"dl,omitempty"` // Actual page's Title // Example: Hire Me DocumentTitle *string `json:"document_title,omitempty" gtag:"dt,omitempty"` // Actual page's Referrer // Example: DocumentReferrer *string `json:"document_referrer,omitempty" gtag:"dr,omitempty"` // Unknown. Value ccd.{{HASH}}. The hash in based on various internal parameters. Some kind of usage hash. // Example: ccd.AAB // Z *string `json:"z,omitempty" gtag:"_z,omitempty"` // This is added when an event is generated from rules (from the admin). Actually is hash of the "GA4_EVENT" string // Example: Q // EventUsage *string `json:"event_usage,omitempty" gtag:"_eu,omitempty"` // Unknown // Example: // EventDebugID *string `json:"event_debug_id,omitempty" gtag:"edid,omitempty"` // If an event contains this parameters it won't be processed and it will show on on the debug View in GA4 // Example: 1 IsDebug *string `json:"is_debug,omitempty" gtag:"_dbg,omitempty"` // Current Payload Name. // Example: page_view EventName *sesamy.EventName `json:"event_name,omitempty" gtag:"en,omitempty"` // It's the total engagement time in milliseconds since the last event. The engagement time is measured only when the current page is visible and active ( ie: the browser window/tab must be active and visible ), for this GA4 uses the window.events: focus, blur, pageshow, pagehide and the document:visibilitychange, these will determine when the timer starts and pauses // Example: 1234 // EngagementTime *string `json:"engagement_time,omitempty" gtag:"_et,omitempty"` // Defines a parameter for the current Payload // Example: ep.page_type: checkout EventParameter map[string]string `json:"event_parameter,omitempty" gtag:"ep,omitempty"` // Defines a parameter for the current Payload // Example: epn.plays_count: 42 EventParameterNumber map[string]string `json:"event_parameter_number,omitempty" gtag:"epn,omitempty"` // Current User ID // Example: 1635691016 UserID *string `json:"user_id,omitempty" gtag:"uid,omitempty"` // Current Firebase ID // Example: HASHSAH // FirebaseID *string `json:"firebase_id,omitempty" gtag:"_fid,omitempty"` // GA4 Session Id. This comes from the GA4 Cookie. It may be different for each Stream ID Configured on the site // Example: 1635691016 SessionID *string `json:"session_id,omitempty" gtag:"sid,omitempty"` // Count of sessions recorded by GA4. This value increases by one each time a new session is detected ( when the session expires ) // Example: 10 // SessionCount *string `json:"session_count,omitempty" gtag:"sct,omitempty"` // If the current user is engaged in any way, this value will be 1 // Example: // SessionEngagment *string `json:"session_engagement,omitempty" gtag:"seg,omitempty"` // Defines an user Propery for the current Measurement ID // Example: up.is_premium_user: yes UserProperty map[string]string `json:"user_property,omitempty" gtag:"up,omitempty"` // Defines an user Propery for the current Measurement ID // Example: UserPropertyNumber map[string]string `json:"user_property_number,omitempty" gtag:"upn,omitempty"` // Example: 1 // GTMUp *string `json:"gtmup,omitempty" gtag:"gtm_up,omitempty"` // Documented values, 1,2,3: Not sure when it's added. // EuropeanConsentModeEnabledID *string `json:"european_consent_mode_enabled_id,omitempty" gtag:"_ecid,omitempty"` // Example: // UEI *string `json:"uei,omitempty" gtag:"_uei,omitempty"` // It's set when a Google Join is created/imported. Google Signals // Example: 1 // CreateGoogleJoin *string `json:"create_google_join,omitempty" gtag:"_gaz,omitempty"` // Example: Redact Device Info. Need Investigation about functionality // RedactDeviceInfo *string `json:"redact_device_info,omitempty" gtag:"_rdi,omitempty"` // Geo Granularity. Need Investigation about functionality // GeoGranularity *string `json:"geo_granularity,omitempty" gtag:"_geo,omitempty"` // Sent on sites that implement the US Privacy User Signal Mechanism, sent if window.__uspapi is present and returning a value. // Example: 1YNY // USPrivacySignal *string `json:"usprivacy_signal,omitempty" gtag:"us_privacy,omitempty"` // Sent on sites that implements IAB GDPR-Transparency-and-Consent-Framework( TCFv2 ) Mechanism. sent if window.__tcfapi is present and returning a valid value. // Example: 1 // GDPR *string `json:"gdpr,omitempty" gtag:"gdpr,omitempty"` // Sent on sites that implements IAB GDPR-Transparency-and-Consent-Framework( TCFv2 ) Mechanism. sent if window.__tcfapi is present and returning a valid value. // Example: CPfPdAAPfPdAAAHABBENCgCsAP_AAAAAAAAAI_tf_X__b3_j-_5___t0eY1f9_7__-0zjhfdl-8N3f_X_L8X_2M7vF36tq4KuR4Eu3LBIQdlHOHcTUmw6okVrzPsbk2cr7NKJ7PEmnMbeydYGH9_n1_z-ZKY7_____77__-____3_____-_f___5_3____f_V__97fn9_____9_P___9v__9__________3___gAAAJJQAYAAgj-GgAwABBH8VABgACCP5SADAAEEfx0AGAAII_kIAMAAQR_CQAYAAgj-IgAwABBH8ZABgACCP4A.f_gAAAAAAAAA // GDPRConsent *string `json:"gdprconsent,omitempty" gtag:"gdpr_consent,omitempty"` // Example: sypham NonPersonalizedAds *string `json:"non_personalized_ads,omitempty" gtag:"npa,omitempty"` // Example: 1 // ARE *string `json:"are,omitempty" gtag:"are,omitempty"` // PrivacySandboxCookieDeprecationLabel *string `json:"privacy_sandbox_cookie_deprecation_label,omitempty" gtag:"pscdl,omitempty"` // A timestamp measuring the difference between the moment this parameter gets populated and the moment the navigation started on that particular page. // TFD *string `json:"tfd,omitempty" gtag:"tfd,omitempty"` SST *SST `json:"sst,omitempty" gtag:"sst,omitempty"` Remain map[string]any `json:"-" gtag:"-,omitempy,remain"` }
Payload https://www.thyngster.com/ga4-measurement-protocol-cheatsheet/
type SST ¶
type SST struct { // Example: 1 ADR *string `json:"adr,omitempty" gtag:"adr,omitempty"` // Example: 1--- USPrivacy *string `json:"us_privacy,omitempty" gtag:"us_privacy,omitempty"` // Example: 542231386.1709295522 RND *string `json:"rnd,omitempty" gtag:"rnd,omitempty"` // Example: google.de ETLD *string `json:"etld,omitempty" gtag:"etld,omitempty"` // Example: region1 GCSub *string `json:"gcsub,omitempty" gtag:"gcsub,omitempty"` // Example: DE UC *string `json:"uc,omitempty" gtag:"uc,omitempty"` // Session start time, time first seen. Example: 1708250245344 TFT *string `json:"tft,omitempty" gtag:"tft,omitempty"` // Example: 13l3l3l3l1 GCD *string `json:"gcd,omitempty" gtag:"gcd,omitempty"` // Example: 0 UDE *string `json:"ude,omitempty" gtag:"ude,omitempty"` }
Click to show internal directories.
Click to hide internal directories.