I've successfully integrated an analytics solution for Tier 1 projects.
It's based on PIWIK, an open source solution, that can be found here:
www.piwik.org
You will need to install the software to your server, or hosted server first. You can find plenty of references to the HTTP options here:
http://developer.piwik.org/api-reference/tracking-api
And here is an example piece of code from my Slots Game that demonstrates registering the device on bootup.
You'll need to change the URL's to point to your own server.
Use StatPiwik () to initialse and register the first bootup
call PiwikManager () from within your main loop.
//
//Piwik Analytics -
//
Type _type_Piwik
state as integer
http as integer
EndType
Type _type_piwik_que
event as string[]
EndType
//
// Call this to initialise Piwik Analytics & send the first event to the server.
//
Function Init_Piwik ()
Global Piwik as _type_Piwik
Global PiwikQue as _type_piwik_que
#constant PIWIK_STATE_PROCESSING = 1
StartPiwik ()
PiwikCustomVar_DeviceType ( )
EndFunction
//
// Updates all analytics function. Call this from your main loop.
//
Function PiwikManager ()
Select Piwik.state
case PIWIK_STATE_PROCESSING
ProcessPiwikQue ()
endcase
EndSelect
EndFunction
//
// Process the que for events to send to analytics
//
Function QuePiwik ( event as string )
PiwikQue.event.insert(event)
Piwik.state = PIWIK_STATE_PROCESSING
EndFunction
//
// Check last command was processed, and send new command to piwik.
//
// piwikurl$ is the folder location of Piwik on your server.
//
Function ProcessPiwikQue ()
piwikurl$ = "/analytics/piwik/piwik.php"
if GetInternetState()
if GetHTTPResponseReady( Piwik.http ) and PiwikQue.event.length > -1
SendHTTPRequestASync ( Piwik.http , piwikurl$ ,PiwikQue.event[0] )
PiwikQue.event.remove (0)
if PiwikQue.event.length <0 then Piwik.state = 0
endif
endif
EndFunction
//
// Open HTTP and initialise state.
//
// Set host$ to your server url
//
Function StartPiwik ()
host$ = "www.YOUR SERVER URL.com"
Piwik.http = CreateHTTPConnection ()
SetHTTPHost ( Piwik.http ,host$ ,0 )
Piwik.state = 0
EndFunction
//
// End All Piwik analytics process and close HTTP connection
//
Function EndPiwik ()
CloseHTTPConnection ( Piwik.http )
DeleteHTTPConnection ( Piwik.http )
Piwik.state = 0
Endfunction
//
// Register the device type + Bootup
//
// url$ = doesn't need to be a real URL, and can point different pages/screens of your game
//
Function PiwikCustomVar_DeviceType ( )
url$ = "&url=http://KingoSlots/Start"
var$ = "&_cvar={"+adin("1")+":["+adin("Device")+","+adin(GetDeviceName())+"]}"
QuePiwik ( PiwikRequiredSTR () + url$+var$ )
EndFunction
//
// Add invreted to commas to a string value
//
Function adin ( tmpstr as string )
tmpstr = chr(34) + tmpstr + chr (34 )
EndFunction tmpstr
//
// All the basic info needed with each HTTP tracking event.
//
// idsite$ = the app/web page id number
//
Function PiwikRequiredSTR ()
id$ = "id="+ right ( GetDeviceID (), 16 )
uid$= "&uid="+GetDeviceID ()
ip$ = GetDeviceIP ()
time$=GetCurrentTime()
time_hour$ = "&h="+Left(time$,2)
time_min$ = "&m="+mid (time$,4,2)
time_sec$ = "&s="+Right ( time$, 2)
rnd$ = str ( random ( 1,10000) )
idsite$ = "&idsite=1"
rec$ = "&rec=1"
tmpstr$ = id$+uid$+time_hour$+time_min$+time_sec$+rnd$+idsite$+rec$
EndFunction tmpstr$