cbdw2014 - using a coldbox module to connect to the google analytics api
DESCRIPTION
Setup a Google Project to connect the Google Analytics API Setting up an oAuth 2.0 account Downloading and setting up the Google API jar files Adding your parameters to connect to the GA API Connect now through oAuth. Print ReportTRANSCRIPT
Get Analytics with:
By George Murphy
About Me
• Contractor
• ColdFusion since version 4.5
• Member Team ColdBox
• ColdFusion, JavaScript, and Angular JS
5
Setup CommandBox & a Google Project
4
3
2
1
Setting up an oAuth 2.0 account
Downloading Google API jar files
Add parameters to CB module
Connect through oAuth
Setup Steps for Get Analytics
What is Google Analytics
It is a service offered by Google that generates detailed statistics about a website's traffic and traffic sources and measures conversions and sales.
Download CommandBox
Unzip CommandBox
Open CMDCD to dir where CB
is unzipped
box
CD to dir where you want project
coldbox create app anal --
installColdBoxBE
Server start 52217 --force
Forgebox install javaloader
Setup CommandBox?
Let’s setup CommandBox
Setup Google Project
Setup Permissions
oAuth 2.0 Authentication
Download Google Jars
Setup ModuleConfig
Setup a Google Project
https://console.developers.google.com/project
SettingsModuleConfig.cfc settings
settings = {scope = "https://www.googleapis.com/auth/analytics.readonly",client_id = “***********.apps.googleusercontent.com",client_secret = “************",redirect_uri = "http://127.0.0.1:52217/index.cfm/ga/home/index",state = "optional"
};
routes = [{pattern="/", handler="home",action="index"},{pattern="/home/index", handler="home",action="index"},{pattern="/home/test", handler="home",action="test"},{pattern="/home/siteSelect", handler="home",action="siteSelect"},{pattern="/home/dateRange", handler="home",action="dateRange"},{pattern="/:handler/:action?"}
];
binder.map("googleService@ga").to( "#moduleMapping#.models.googleService" );binder.mapDirectory("#moduleMapping#.models");
function onLoad(){controller.getWireBox().getInstance('googleService@ga');
}
Do you have
any questions?
Resources
• CommandBox Downloadhttp://www.ortussolutions.com/products/commandbox
• Google Projecthttps://console.developers.google.com/project
• Sample Codehttps://github.com/murpg/coldbox-module-google-analytics-api