Documentation
¶
Overview ¶
Package seaurl parses UTM campaign parameters from URLs. It is shared by the SEA analyzers (utm, landing) so UTM tagging is interpreted consistently and tested once. It depends only on the standard library — analyzers cannot reach the crawler's unexported URL helpers, so all parsing here goes through net/url.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CanonicalUTMKeys = []string{"utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"}
CanonicalUTMKeys are the five standard UTM parameters in canonical (lowercase) form.
var RequiredUTMKeys = []string{"utm_source", "utm_medium", "utm_campaign"}
RequiredUTMKeys are the three keys Google requires for manual campaign tagging. A link carrying some but not all of these is "partially tagged".
Functions ¶
This section is empty.
Types ¶
type UTM ¶
type UTM struct {
Values map[string]string // canonical key -> first non-empty value (trimmed)
Duplicates []string // canonical keys that appeared more than once (sorted)
CasingMixed []string // raw keys that were not already lowercase, e.g. "UTM_Source" (sorted)
Empty []string // canonical keys present only with empty/whitespace values (sorted)
Raw url.Values // the full parsed query, for callers that need more
}
UTM holds the parsed UTM parameters of a single URL.
func Parse ¶
Parse extracts UTM parameters from a raw URL. It is tolerant of parse errors, returning an empty (untagged) UTM rather than failing.
func ParseQuery ¶
ParseQuery is the core parsing logic, exposed for callers that already hold a url.Values. Keys are matched case-insensitively and canonicalized to lowercase; the original casing is recorded in CasingMixed. Outputs are sorted so results are deterministic across the randomized map iteration order.
func (UTM) PresentKeys ¶
PresentKeys returns the canonical UTM keys that appear in the URL (with any value, including empty), in canonical order.