PHP class to send pageViews or Events to Google Analytics without the need of javascript.
Switch branches/tags
Nothing to show
Clone or download
Latest commit db639e9 Jul 14, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.markdown update Jul 6, 2015
ss-ga.class.php update comment Jul 6, 2015



Server Side Google Analytics (SSGA) is a simple PHP 5 class, which allows to track server-side events and data within Google Analytics.

Drop-in solution for WordPress plugins (uses the WP HTTP API if available).


Google Analytics Server Side can be used simply in the following manner:


ssga_track( 'UA-YOUR_NUMBER', '', '/page.php' )


//create new ssga object
include 'lib/ss-ga.class.php';
$ssga = new ssga( 'UA-YOUR_NUMBER', '' );

//Set a pageview
$ssga->set_page( '/page.php' );
$ssga->set_page_title( 'Page Title' );

// Send

Set an event (based on

//$ssga as created above
$ssga->set_event( 'Feed', 'Categories', $label, $value );

Ecommerce tracking (update and test by @nczz)

$ssga_step1 = new ssga( 'UA-12345678-1','' );
//$transaction_id, $affiliation, $total, $tax, $shipping, $city, $region, $country
$ssga_step1->send_transaction("20159527001", "MXP", 280, 0, 80,"Taiwan", "", "TW");

$ssga_step2 = new ssga( 'UA-12345678-1','' );
//$transaction_id, $sku, $product_name, $variation, $unit_price, $quantity
$ssga_step2->send_item("20159527001", "1229001", "TEST-PRODUCT", "", 50, 4);