Skip to content

affise/go-tracking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-tracking GoDoc

Affise tracking SDK for go.

Installation

To install it in the GOPATH:

go get https://github.com/affise/go-tracking

Documentation

The links bellow should provide all the documentation needed to make the best use of the library:

Usage

Clicks

package main

import (
	"log"
	"net/http"

	"github.com/affise/go-tracking"
)

func main() {
	http.HandleFunc("/click", func(w http.ResponseWriter, r *http.Request) {
		// request should contain param click_id/clickid/afclick 
		tracking.MustSetCookie(w, r)
		
		// ...
	})

	err := http.ListenAndServe(":80", nil)
	if err != nil {
		log.Fatalf("server error: %v", err)
	}
}

Conversions

package main

import (
	"log"
	"net/http"

	"github.com/affise/go-tracking"
)

func main() {
	pp := tracking.NewPostbackProvider("offers-client.affise.com", true)
	
	http.HandleFunc("/postback", func(w http.ResponseWriter, r *http.Request) {
		// request should contain first-party cookie 
		err := pp.DoDefaultWithCookie(r, &tracking.Postback{
			ActionID: "advertiser action id",
		})
		if err != nil {
			w.WriteHeader(http.StatusBadRequest)
			return
		}
		
		// ...
	})

	err := http.ListenAndServe(":80", nil)
	if err != nil {
		log.Fatalf("server error: %v", err)
	}
}