seaurl

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 3 Imported by: 0

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

View Source
var CanonicalUTMKeys = []string{"utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"}

CanonicalUTMKeys are the five standard UTM parameters in canonical (lowercase) form.

View Source
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

func Parse(rawURL string) UTM

Parse extracts UTM parameters from a raw URL. It is tolerant of parse errors, returning an empty (untagged) UTM rather than failing.

func ParseQuery

func ParseQuery(q url.Values) UTM

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) Missing

func (u UTM) Missing(required []string) []string

Missing returns the required keys absent from this URL, in the order given.

func (UTM) PresentKeys

func (u UTM) PresentKeys() []string

PresentKeys returns the canonical UTM keys that appear in the URL (with any value, including empty), in canonical order.

func (UTM) Tagged

func (u UTM) Tagged() bool

Tagged reports whether any UTM parameter is present (with a value or empty).

Jump to

Keyboard shortcuts

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