goal

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package goal stores named conversion goals — "what counts as success on this site" — defined once, reusable everywhere. A goal is either an event name (signup) or a path glob (/thanks*, matched against $pageview paths). Resolution answers the founder question: how many unique users converted, at what rate, and which channel sent them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	ID      string    `json:"id"`
	Name    string    `json:"name"`
	Kind    string    `json:"kind"`  // "event" | "path"
	Value   string    `json:"value"` // event name, or path glob like /thanks*
	Created time.Time `json:"created"`
}

Definition is one named goal.

type Report

type Report struct {
	Goal          string `json:"goal"`
	Kind          string `json:"kind"`
	Value         string `json:"value"`
	PeriodDays    int    `json:"period_days"`
	Conversions   int    `json:"conversions"`    // unique users who hit the goal
	Visitors      int    `json:"visitors"`       // unique users seen in the period
	ConversionPct int    `json:"conversion_pct"` // conversions / visitors
	ByReferrer    []Row  `json:"by_referrer"`    // which channel sent the converters
	ByUTMSource   []Row  `json:"by_utm_source"`  // campaign attribution when tagged
}

Report is a resolved goal over a period.

func Resolve

func Resolve(evs []event.Event, d Definition, days int, now time.Time) Report

Resolve computes the goal report over the trailing period. Attribution is first-touch within the period: a converter's channel is the referrer/utm_source on their FIRST event in the window — the founder question is "which channel brought the people who converted", not "what page were they on when they did".

type Row

type Row struct {
	Value string `json:"value"`
	Users int    `json:"users"`
}

Row is one channel's contribution to a goal.

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(p string) (*Store, error)

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) List

func (s *Store) List() []Definition

func (*Store) Save

func (s *Store) Save(d Definition) (Definition, error)

Jump to

Keyboard shortcuts

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