Skip to content

Server-Side Google Analytics Tracking with PHP and Measurement Protocol - No Cookies and Javascript

License

Notifications You must be signed in to change notification settings

sps8/nojs-ga-php-tracking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nojs-ga-php-tracking

Alternate server-side Google-Analytics-Tracking without JavaScript and Cookies. Uses PHP and Google Measurement Protocoll.

Advantages

  • Take control of the data to be transmitted to Google Analytics
  • Track visitors with disabled JavaScript
  • Accelerates page load and site performance

Note: This script doesn't track all data of the original Google Analytics code, especially no data that can only be determined with JavaScript, e.g. the screen resolution. The recognition of returning visitors is only as good as the server-side detection (e.g. login). Currently only the visitor is recognized within a session or by IP.

Installation

Save stat.php in web project folder, e. g. 'inc/stat.php'

Usage

  • Change the variables to be transferred according to your wishes
  • Include script in all pages to track (index.php, ...)
include('YOURPATH/stat.php');

Examples

Event tracking with jquery

function ga(s,t,ec,ea,el,ev){
 $.ajax({ type:"POST", url:"YOURPATH/stat.php", data:{"type":t,"ec":ec,"ea":ea,"el":el,"ev":ev} })
}

ga('send','event','CATEGORIE','ACTION','LABEL','VALUE')

Options

For all parameters look at Google Measurement Protocoll

About

Server-Side Google Analytics Tracking with PHP and Measurement Protocol - No Cookies and Javascript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages