Using Google Analytics

Is it possible to use Google Analytics with Xojo Cloud? If so, I am looking for some general pointers before I try getting into this.

I’m not using Google Analytics or Xojo Cloud but it should be the same as using Piwik. You just have a javascript or image tracking code on each of your web pages that points to the Web analytics server.

If you have your own web server and concerned what google should have of informations.

You could setup your own Piwik Analytics web server.

See Demo: http://demo.piwik.org/index.php?module=CoreHome&action=index&idSite=7&period=day&date=yesterday#/module=Dashboard&action=embeddedIndex&idSite=7&period=day&date=yesterday&idDashboard=1

Where to download Piwik: http://piwik.org

That looks impressive. I always thought GA was king but I am going to have to look into Piwik. Thanks.

I am not giving up on GA yet so I am still interested in hearing from GA + Xojo Cloud users.

Unfortunately it’s not that simple. Google analytics requires that the JavaScript actually run on each page, so you’re probably going to need to create an sdk control to trigger it for each page load.

I am getting back into this and need to ask some followup questions.

I have read that it is best to place the Google Analytics tracking code script immediately before the tag.

I can do this for the very first page because it is just an html page that does a redirect to the first page in the Xojo app.

For pages in Xojo, it sounds like it isn’t impossible to do this but it might be tricky. For example, I don’t think I can have the tracking script load after the tag. If I put it in EditSource, would it still work? I am guessing that the answer is yes but it just wouldn’t accurately track everything that happens on the page (which is not a problem in my case).

By the way, I don’t care if this works on every page. I would be happy with just tracking first and last pages. If I have to, I will make the final page a separate html page.

Also, does Google’s Universal Analytics mean it will work better with Xojo?

[quote=115821:@Ken Gish]I am getting back into this and need to ask some followup questions.

I have read that it is best to place the Google Analytics tracking code script immediately before the tag.

I can do this for the very first page because it is just an html page that does a redirect to the first page in the Xojo app.

For pages in Xojo, it sounds like it isn’t impossible to do this but it might be tricky. For example, I don’t think I can have the tracking script load after the tag. If I put it in EditSource, would it still work? I am guessing that the answer is yes but it just wouldn’t accurately track everything that happens on the page (which is not a problem in my case).

By the way, I don’t care if this works on every page. I would be happy with just tracking first and last pages. If I have to, I will make the final page a separate html page.

Also, does Google’s Universal Analytics mean it will work better with Xojo?[/quote]

It is very important for Google to be able to index pages in order for Web Analytics to work, which is difficult with a Xojo web app, but not impossible. Matthew Combatti has outlined an interesting method in
https://forum.xojo.com/13445-is-xojo-web-for-web-sites

That said, I have to repeat what I said in that thread : Google likes best text content and keywords it finds on web sites. It also sets the pagerank from direct links from web sites to pages within yours. In the case of a web app, the interface is inherently poorer than an HTML based site, because an app is made of controls rather than hypertext.

Instead of making it a simple redirect, you may want to add a lot of content to your redirect page and even ways to get to precise webpages into your app through a menu of links to help Web Analytics index the content of your site. Companies that specialize in search engine optimization often collect large quantities of text information related to the web site and cram it into html pages just to add indexes. I have also seen many times the first results of a Google search be single html pages, but with a lot of literature.

See this for more about making your site more visible to Google :
http://static.googleusercontent.com/media/www.google.com/en//webmasters/docs/search-engine-optimization-starter-guide.pdf

The more text you can cram into your HTML pages, the happier Google will be to index them and elevate your site pagerank. Make sure to link from your first page to the last, so GoogleBot can find it. And do not forget to provide a link from the last page to the first, for the user to be able to easily restart if he wants to. You never know where a visitor using a search engine is going to land, so providing a link to the index page is always a good idea.

Awesome response! Thanks.

I did read your and Matthew’s posts in that thread you mentioned but I think my main question is at a much more basic level. It seems to me Google Analytics tracking code should work on any page you put the tracking code on (using EditSource or other means within Xojo). Is that true? I am viewing Real-Time Overview in Google Analytics and it looks my session is showing up. I have to experiment to see if it is getting enough information; I want to get statistics on OS, browsers and display resolution. My confusion is that it seems like GA works with Xojo but everyone seems to say it doesn’t work. I am clearly missing something here.

I need to clarify a couple things. We primarily want the Google Analytics to tell us how many people start (and, to a lesser extent, finish) the Xojo app. Having a high pagerank would be great so I will try putting keywords in the first page (the redirect page).

Also, the navigation through our app must be the same for everyone; it is crucial that people can’t start on any page they choose. Because of this, I don’t want to track anything but the first and last pages.

I intend to do as you suggest and link from last page to first page and vice versa. Very good idea.

If your app is WebPage based you could log users navigation within your app in the WebPage open and append to the log the IP of the user. And use Session.TimedOut to see when and where the user has exited. The WebContainer approach (One page several containers) would need a different tracking but it can be done along the same principle.

That way you can see to which webpages the user has navigated, how long he spent there, and at which page he decided to abandon the app. When you have many visitors an app that processes the log maybe necessary.

Tracking code inserted in EditSource of a WebPageSource component doesn’t seem to be working. Is there any way to get this to work?

Maybe you can instead run the Google JavaScript in the shown event with ExecuteJavaScript. See Add analytics.js to Your Site  |  Analytics for Web (analytics.js)  |  Google for Developers

That worked! Thank you, thank you, thank you.

That’s not going to work for detecting where a user left your app. It depends on the browser actually being there and the user having been idle for a period of time to fire the event.

I’d suggest that you just keep track of the pages that the user visits. When the session finally dies off, subtract 3 minutes from the last page’s time (the default session timeout period).

[quote=116791:@Greg O’Lone]That’s not going to work for detecting where a user left your app. It depends on the browser actually being there and the user having been idle for a period of time to fire the event.

I’d suggest that you just keep track of the pages that the user visits. When the session finally dies off, subtract 3 minutes from the last page’s time (the default session timeout period).[/quote]

The idea was not far from what you suggest. As long as the user navigates the app, it is possible to track the time a user spends on each WebPage since he changes webpage. When he decides to abandon, since WE does not provide CancelLoad, it is impossible to know he clicked off. So TimedOut time minus TimeOut would have produced the time he exited.

At any rate, since Ken has got GA to track his pages, this becomes a bit academic.

Unfortunately that’s not true. Session.Timeout is the amount of time that a browser is allowed to be idle while still pointed at the app before the TimedOut event fires. If a user were to leave the app entirely, the TimedOut event would never fire. Academic or not, I’m just trying to make sure that the suggestions are relevant and accurate.

I appreciate your insight. So instead of TimedOut, Close should be used, right ?

The Session.Close event, yes.

Alright. Thank you.