Bug 2079 - Google Analytics bindings are missing methods
Summary: Google Analytics bindings are missing methods
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-11-17 12:44 UTC by Hipolyto
Modified: 2011-11-28 17:35 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Google Analytics 1.4 binding for MonoTouch (1.20 MB, application/x-msdownload)
2011-11-25 20:46 UTC, Miguel de Icaza [MSFT]
Updated GoogleAnalytics (1.20 MB, application/octet-stream)
2011-11-28 15:17 UTC, Miguel de Icaza [MSFT]
App Crash Sample (437.89 KB, application/zip)
2011-11-28 15:54 UTC, Hipolyto

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Hipolyto 2011-11-17 12:44:01 UTC
for details see: 

In realese mode the app is crashing when this line is executed:

var tracker = GoogleAnalytics.GANTracker.SharedTracker;
Another question, I need to also implement these functions:

Can MonoTouch support this?

Comment 1 Sebastien Pouliot 2011-11-17 12:54:28 UTC
Let's keep the crash in bug #2062
and the missing bindings in this bug report
Comment 2 Hipolyto 2011-11-17 13:04:22 UTC

Is it possible to add these features with a new interface? and I can generate a new dll or do I need to send the source?
Comment 3 Hipolyto 2011-11-17 15:44:24 UTC
any comments?
Comment 4 Hipolyto 2011-11-18 14:21:21 UTC
Do I need to add another bug?
Comment 5 Hipolyto 2011-11-22 11:10:36 UTC
Hello, any news?
Comment 6 Sebastien Pouliot 2011-11-23 16:14:54 UTC
does not exists anymore. Do you still have an old copy around so we can update
this sample (and bindings) to the latest version ?
Comment 7 Hipolyto 2011-11-24 13:58:40 UTC
this bindings is posible?
Comment 8 Miguel de Icaza [MSFT] 2011-11-25 14:31:57 UTC

The bindings for a few libraries are on an old module that it seems we never imported into MonoTouch-Bindings, they are here:


We probably should turn these into actual bindings.   

The sample was trivial, I have included the source, I got it doing a checkout of monotouch-samples like this:

 git checkout 92330be9e3b0ea8c7a57e4b32009481981b55503

using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;

namespace GoogleAnalytics
	public class Application
		static void Main (string[] args)
			UIApplication.Main (args);

	public partial class AppDelegate : UIApplicationDelegate
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
			// Replace with your account information.
			var account = "UA-000000-1";
			int time = 10;
			var tracker = GoogleAnalytics.GANTracker.SharedTracker;
			tracker.StartTracker (account, time, null);
			var label = new UILabel (new RectangleF (10, 10, 300, 20));
			NSError error;
			if (tracker.TrackPageView ("/app_entry_point", out error))
				label.Text = "Tracking successfully sent!";
				label.Text = "Error starting tracker";
			// Force the event to be sent
			tracker.Dispatch ();
			window.AddSubview (label);
			window.MakeKeyAndVisible ();
			return true;

		// This method is required in iPhoneOS 3.0
		public override void OnActivated (UIApplication application)
Comment 9 Miguel de Icaza [MSFT] 2011-11-25 20:46:12 UTC
An updated version of the binding now lives in monotouch-bindings.

I have attached the self-contained DLL, you no longer need to pass any arguments to mtouch to use this, merely reference this assembly.  It comes with the various extra methods for transactions.
Comment 10 Miguel de Icaza [MSFT] 2011-11-25 20:46:50 UTC
Created attachment 950 [details]
Google Analytics 1.4 binding for MonoTouch
Comment 11 Hipolyto 2011-11-25 22:04:55 UTC
Comment 12 Hipolyto 2011-11-28 10:18:33 UTC
Hello the TrackPageView and TrackEvent is missing in the dll.
Comment 13 Miguel de Icaza [MSFT] 2011-11-28 10:25:11 UTC
I added those events, but we found that the library that Google shipped for NoThumb is broken, so the solution will not work.
Comment 14 Hipolyto 2011-11-28 10:28:40 UTC
So what is the solution?

Do I have to decide for only one solution?

Comment 15 Miguel de Icaza [MSFT] 2011-11-28 15:17:20 UTC
Created attachment 962 [details]
Updated GoogleAnalytics

Updated version of the assembly with the entry points that were previously hidden, plus a workaround for Google's broken binaries.
Comment 16 Miguel de Icaza [MSFT] 2011-11-28 15:18:04 UTC

Please use my updated assembly, it fixes your reported problem and works now.
Comment 17 Hipolyto 2011-11-28 15:21:21 UTC
I think I'll have to buy you a drink, I'll try and let you know.

Comment 18 Hipolyto 2011-11-28 15:41:15 UTC
I get this error:

[ERROR] FATAL Unhandled Exception: System.InvalidCastException: Can not cast from source type to destination type.

var tracker = GoogleAnalytics.GANTracker.SharedTracker;//   .GANTracker.SharedTracker;
 GoogleAnalytics.GANTracker.SharedTracker.StartTracker (Acointid, time, null);

Any idea?
Comment 19 Hipolyto 2011-11-28 15:45:11 UTC
I clean and rebuil the proyect and now get this error:
Error trackView: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[GANAdHitIdGenerator adHitId]: unrecognized selector sent to instance 0xd76a330
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:bool_objc_msgSend_IntPtr_IntPtr (intptr,intptr,intptr,intptr)
  at GoogleAnalytics.GANTracker.TrackPageView (System.String pageUrl, MonoTouch.Foundation.NSError& nsError) [0x00000] in <filename unknown>:0
Comment 20 Hipolyto 2011-11-28 15:54:55 UTC
Created attachment 963 [details]
App Crash Sample

App Crash Sample
Comment 21 Miguel de Icaza [MSFT] 2011-11-28 17:32:23 UTC

I am afraid you wont be able to use that method, since Google shipped a broken
version of the _NoThumb library and it seems that you hit on the feature that
our workaround tries to hide:

2011-11-28 17:29:56.220 AppGA[7339:1907] -[GANAdHitIdGenerator adHitId]:
unrecognized selector sent to instance 0xba7a830

That is precisely because GANAdHitIdGenerator is not included in the
libGoogleAnalytics_NoThumb.a so we provided an empty stub for it.   You need to
bring this up with Google, I posted a bug report ealier today about this.
Comment 22 Hipolyto 2011-11-28 17:35:59 UTC
Ok,  thanks.