utm

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 2 Imported by: 0

README

UTM Tag Builder

Travis Go Report Card codecov

Use UTM Tag Builder to add Google utm tags to a URL.

Installation

go get -u github.com/adamlc/go-utm

Usage

url, err := utm.BuildURL("https://test.com", utm.Config{
	Source: "google",
	Medium: "email",
	Campaign: "Awesome Test"},
)

// https://test.com?utm_campaign=Awesome+Test&utm_medium=email&utm_source=google
func BuildURL
func BuildURL(rawurl string, config Config) (string, error)

BuildURL adds UTM tags to the passed URL

type Config
type Config struct {
	Source   string
	Medium   string
	Campaign string
	Content  string
	Term     string
}

Config is used to configure UTM tags for a URL

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrURLRequired is thrown when the URL passed is empty
	ErrURLRequired = errors.New("A URL is required")

	// ErrInvalidURL is thrown when the passed URL doesn't validate
	ErrInvalidURL = errors.New("The URL is invalid")

	// ErrSourceRequired is thrown when no source is passed
	ErrSourceRequired = errors.New("A Source is required")

	// ErrMediumRequired is thrown when no source is passed
	ErrMediumRequired = errors.New("A Medium is required")

	// ErrCampaignRequired is thrown when no campaign is passed
	ErrCampaignRequired = errors.New("A Campaign is required")
)

Functions

func BuildURL

func BuildURL(rawurl string, config Config) (string, error)

BuildURL adds UTM tags to the passed URL

Types

type Config

type Config struct {
	Source   string
	Medium   string
	Campaign string
	Content  string
	Term     string
}

Config is used to configure UTM tags for a URL

Source Files

  • utm.go

Jump to

Keyboard shortcuts

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