Skip to content

Commit

Permalink
Added in Google Analytics bindings for v1.2 with sample application.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisntr committed Sep 6, 2011
1 parent d4dec7d commit e6b0721
Show file tree
Hide file tree
Showing 16 changed files with 1,001 additions and 0 deletions.
67 changes: 67 additions & 0 deletions GoogleAnalytics/v1.2/Binding/GoogleAnalytics.cs
@@ -0,0 +1,67 @@
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
using MonoTouch.CoreLocation;

namespace GoogleAnalytics
{
[BaseType (typeof (NSObject))]
interface GANTracker {

[Export ("debug")]
bool Debug { get; set; }

[Export ("dryRun")]
bool DryRun { get; set; }

[Static] [Export ("sharedTracker")]
GANTracker SharedTracker { get; }

[Export ("startTrackerWithAccountID:dispatchPeriod:delegate:")]
void StartTracker (string accountId, int dispatchPeriod, [NullAllowed] GANTrackerDelegate ganDelegate);

[Export ("stopTracker")]
void StopTracker ();

[Export ("trackPageview:withError:")]
bool TrackPageview (string pageURL, out NSError error);

[Export ("trackEvent:action:label:value:withError:")]
bool TrackEvent (string category, string action, string label, int value, out NSError error);

[Export ("setCustomVariableAtIndex:name:value:scope:withError:")]
bool SetCustomVariableWithScope (int index, string name, string value, int scope, out NSError error);

[Export ("setCustomVariableAtIndex:name:value:withError:")]
bool SetCustomVariable (int index, string name, string value, out NSError error);

[Export ("getVisitorCustomVarAtIndex:")]
string GetVisitorCustomVar(int index);

[Export ("addTransaction:totalPrice:storeName:totalTax:shippingCost:withError:")]
bool AddTransaction (string orderId, double totalPrice, string storeName, double totalTax, double shippingCost, out NSError error);

[Export ("addItem:itemSKU:itemPrice:itemCount:itemName:itemCategory:withError:")]
bool AddItem (string orderID, string itemSKU, double itemPrice, double itemCount, string itemName, string itemCategory, out NSError error);

[Export ("trackTransactions:")]
bool TrackTransactions (out NSError error);

[Export ("clearTransactions:")]
bool ClearTransactions (out NSError error);

[Export ("dispatch")]
bool Dispatch ();

}

[BaseType (typeof (NSObject))]
interface GANTrackerDelegate {

[Export ("trackerDispatchDidComplete:eventsDispatched:eventsFailedDispatch:")]
void DispatchCompleted (GANTracker tracker, int eventsDispatched, int eventsFailedDispatch);

}
}
Binary file not shown.
49 changes: 49 additions & 0 deletions GoogleAnalytics/v1.2/Binding/README.md
@@ -0,0 +1,49 @@
Google Analytics iOS SDK
========================

This folder contains the bindings for the Google Analytics iOS SDK.
This is currently bound to version [1.2 of the SDK](http://code.google.com/mobile/analytics/download.html)

Please help and fix any bugs/issues that you see. Accepting pull requests 24/7.

Build
=====
Navigate to this directory in terminal and run the following command
/Developer/MonoTouch/usr/bin/btouch GoogleAnalytics.cs
This will produce you a GoogleAnalytics.dll assembly, which you can use in your MonoTouch projects.

You will also need to make sure you have the libGoogleAnalytics_NoThumb.a in your project (this can be found in the downloaded SDK download) and the following extra arguments set in your iPhone Build section as
-gcc_flags "-L${ProjectDir} -lGoogleAnalytics_NoThumb -framework CFNetwork -lsqlite3.0 -ObjC -all_load"

Known Issues
============

The DryRun property being set causes an Objective-C, need more investigation on this issue.

License
=======

Copyright (c) 2011 Xamarin Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Authors
=======
Chris Hardy
Miguel De Icaza
26 changes: 26 additions & 0 deletions GoogleAnalytics/v1.2/Sample/GoogleAnalyticsSample.sln
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalyticsSample", "GoogleAnalyticsSample\GoogleAnalyticsSample.csproj", "{73283EAA-DA55-455F-8F72-F070E3F2242B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Debug|iPhone.ActiveCfg = Debug|iPhone
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Debug|iPhone.Build.0 = Debug|iPhone
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Release|iPhone.ActiveCfg = Release|iPhone
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Release|iPhone.Build.0 = Release|iPhone
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{73283EAA-DA55-455F-8F72-F070E3F2242B}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = GoogleAnalyticsSample\GoogleAnalyticsSample.csproj
EndGlobalSection
EndGlobal

0 comments on commit e6b0721

Please sign in to comment.