facebook-conversions-go

module
v0.0.0-...-4526b33 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT

README

Meta/Facebook Conversions API

A mostly-generated api client for the Meta conversions API. It is generated from the swagger definitions. There is only a tiny wrapper added to make the api sane.

Example

import (
	"github.com/THOUSAND-SKY/facebook-conversions-go/pkg/facebookgen"
	"github.com/THOUSAND-SKY/facebook-conversions-go/pkg/facebook"
)

a := facebook.New(facebook.APIInput{
	AccessToken: tt.fields.accessToken,
	PixelID:     tt.fields.pixelID,
	Timeout:     tt.fields.timeout,
})
got, err := a.PostEvent(ctx, facebookgen.EventRequest{
	TestEventCode: "TEST123", // remove this before putting in production.
	Data: []facebookgen.Event{
		{
			EventName:      "Purchase",
			EventTime:      time.Now().Unix(),
			EventSourceUrl: "https://example.com",
			EventId:        fmt.Sprintf("EventID%v", time.Now().Unix()),
			UserData: &facebookgen.UserData{
				ClientIpAddress: "11.111.11.111",
				Country:         "en",
				ClientUserAgent: "Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0",
			},
			CustomData: &facebookgen.CustomData{
				Value:       1.00,
				Currency:    "USD",
				ContentType: "product",
				OrderId:     "123444567",
				ContentIds:  []string{"1234456"},
			},
		},
	},
})

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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