Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/indiejustice/google-analytics

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/indiejustice/google-analytics

  • v0.0.0-20190319230318-fa110ab39a65
  • Source
  • Go
  • Socket score

Version published
Created
Source

Build Status Build Status license

Google-Analytics

An easy-to-use Google Analytics API (v1) via Measurement Protocol with golang

Installation

go get github.com/OzqurYalcin/google-analytics

Measuring Purchases Example

package main

import (
	"net/http"
	"time"

	"github.com/OzqurYalcin/google-analytics/src"
	"github.com/google/uuid"
)

func main() {
	http.HandleFunc("/", view)
	server := http.Server{Addr: ":8080", ReadTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second}
	server.ListenAndServe()
}

func view(w http.ResponseWriter, r *http.Request) {
	api := new(ga.API)
	api.Lock()
	defer api.Unlock()
	api.UserAgent = r.UserAgent()
	api.ContentType = "application/x-www-form-urlencoded"

	client := new(ga.Client)
	client.ProtocolVersion = "1"
	client.ClientID = uuid.New().String()
	client.TrackingID = "UA-xxxxxxxx-x"
	client.HitType = "pageview"
	client.DocumentLocationURL = "https://www.example.com/payment"
	client.DocumentTitle = "Payment"
	client.DocumentEncoding = "UTF-8"

	product := new(ga.Product)
	product.SKU = "P1234"
	product.Name = "product name"
	product.Brand = "product brand"
	product.Price = "1.00"
	product.Quantity = "1"
	client.Products = append(client.Products, product)
	client.ProductAction = "purchase"
	client.TransactionID = "T1234"
	client.TransactionRevenue = "1.00"
	client.CurrencyCode = "TRY"

	if r.URL.Path == "/" {
		api.Send(client)
	}
}

FAQs

Package last updated on 19 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc