https://github.com/affise/go-tracking
https://github.com/affise/go-tracking
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/affise/go-tracking
- Owner: affise
- License: mit
- Created: 2024-02-08T14:07:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-14T12:21:18.000Z (over 1 year ago)
- Last Synced: 2025-01-03T22:49:08.684Z (5 months ago)
- Language: Go
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-tracking [](https://godoc.org/github.com/affise/go-tracking)
Affise tracking SDK for go.
## Installation
To install it in the GOPATH:
```
go get https://github.com/affise/go-tracking
```
## DocumentationThe links bellow should provide all the documentation needed to make the best
use of the library:- [Documentation](https://help-center.affise.com/en/articles/6466563-postback-integration-s2s-admins)
- [godoc](https://godoc.org/github.com/affise/go-tracking)## Usage
### Clicks
```go
package mainimport (
"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
```go
package mainimport (
"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)
}
}```