Download the PHP package gradosevic/easy-ga without Composer
On this page you can find all versions of the php package gradosevic/easy-ga. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gradosevic/easy-ga
More information about gradosevic/easy-ga
Files in gradosevic/easy-ga
Package easy-ga
Short Description PHP Google Analytics library for easy use
License MIT
Informations about the package easy-ga
easy-ga
PHP Google Analytics library for quick and easy use
About
This library was created for people who want to start using Google Analytics Measurement Protocol with minimum time for setup. It is basically a wrapper for theiconic/php-ga-measurement-protocol with easy to use objects.
For more information about API please check:
Installation
composer require gradosevic/easy-ga
Supported Features
- Send Events
- Send Page Views
- Send Custom Data
- Send Transactions
- Send Exceptions
Configuration
Minimal
or
Default
Sending Events
Send simple event
that's it!
Send complete event using constructor
Send complete event using Event class methods
Sending Page Views
Minimal
Complete
Sending Custom Data
To send custom data we need to define it in Google Analytics first:
- Log in to Google Analytics
- Go to Admin tab
- Select Account
- In property column click on Custom Definitions->Custom Dimensions
- Click on +New Custom Dimension, give it a name, scope -> Hit and make sure it's active
- Click Create
- Remember index (it will be used in Easy GA)
- Click on Custom Definitions->Custom Metrics
- Click on +New Custom Dimension, give it a name, scope -> Hit, Type -> Integer, make sure it's active
- Click Create
- We have created custom dimension with index 1. Repeat the process for new data
To read custom data:
- Go to Reporting -> Behaviour -> Events -> Overview
- Click on Event Actions
- Click on action with custom data: "Custom Data Action" (in our example)
- Click on Secondary Dimension dropdown
- Choose Custom Dimensions -> [your_custom_dimension_name]
- Number of hits with custom data should appear in the table
Sending Transactions
Minimal
Complete
Looping through products (example)
In case you need to loop throug products, you should unchain Easy GA like this:
Product properties
Product has following properties:
- category
- brand
- coupon
- name
- position
- price
- quantity
- sku
- variant
To set all product's properties, create new product object and use setter methods:
To read transactions:
- Wait for about 10 minutes or less to see the data
- Go to Reporting -> Conversions -> E-commerce -> Overview
- Click on time filter on right (Hourly, Day) and Revenue Sources below to see the data
- Click on other options under E-commerce to see other reports
- Important: Sometimes the data is not shown and you need to click on some filters to show it (time filters or links below)
Sending Exceptions
To show custom exceptions in Dashboard please follow this tutorial:
Advanced: Access to All API Methods
Easy GA objects provide simplest possible set of data to send to GA. If you need to set more data, you can always access underlying library API and all it's methods, simple by using api()
method whenever you need it in code.
Example: Use Easy GA for required data and add other data from API:
Tests
For other examples how to use this library, please look at the tests in the library
License
Easy GA is licensed under the MIT license
Author: Goran Radosevic