Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Shopify/goreferrer

Repository files navigation

goreferrer (No longer maintained)

⚠️ NOTE: This project is not maintained and will not receive any updates or compatibility fixes for future versions of Go ⚠️

A Go module that analyzes and classifies different kinds of referrer URLs (search, social, ...).

Example

package main

import (
	"fmt"

	"github.com/Shopify/goreferrer"
)

var urls = []string{
	"http://ca.search.yahoo.com/search?p=hello",
	"https://twitter.com/jdoe/status/391149968360103936",
	"http://yoursite.com/links",
}

func main() {
	for _, url := range urls {
		r := goreferrer.DefaultRules.Parse(url)
		switch r.Type {
		case goreferrer.Search:
			fmt.Printf("Search %s: %s\n", r.Label, r.Query)
		case goreferrer.Social:
			fmt.Printf("Social %s\n", r.Label)
		case goreferrer.Indirect:
			fmt.Printf("Indirect: %s\n", r.URL)
		}
	}
}

Result:

Search Yahoo: hello
Social Twitter
Indirect: http://yoursite.com/links

About

Analyzes and classifies different kinds of referrer URLs

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages