Google Analytics for user testing in Axure RP9

I have an interface prototype that I’m hoping to collect user data on. I am specifically interested in tracking events (e.g. when are buttons clicked?), and from what I have seen online it seems like Google Analytics should work.

I’ve added the GA plugin to the file on Axure Cloud. The problem I am facing currently is that I can’t figure out how to add JavaScript to individual buttons; I have seen other threads where people simply apply an interaction that opens a link with the code (e.g. “Javascript:ga(‘send’, ‘event’,…); etc.”) which is supposed to then send the event data to GA. I am having no such luck. Any ideas?

I’ve been working on this today and it seems to be working :slight_smile:

The basic idea is that you can execute a JS function in axure by adding an ‘open link’ interaction and specify a ‘link to external url’ with a javascript string e.g javascript:console.log('hello');

I added the Google Analytics Global site tag (gtag.js) as a plugin to the header in axure cloud. Then I can send a custom event to GA by pasting the following in the ‘link to external url’ field

javascript:this.gtag('event', 'TestButton', {
  'dragger_position': '[[ (LVAR1.x - 25) / 325 ]]',
  'question_number': '1'
});

As you can see you can get quite creative with the data you send to GA. In this example dragger_position is the position of a slider that the user can drag around (the slider button is stored in a local variable: LVAR1).

See also the GA docs for events: https://developers.google.com/analytics/devguides/collection/gtagjs/events

Hey Paul, thanks so much for your response! Sorry I’m getting back to you so late - I had finished this project by the time you responded.

I’m now attempting to use the same prototype for a new project, and once again attempting to export data from the prototype to GA. I’m not very familiar with JS - is there any chance you could explain a bit about this chunk of code? For instance, what does “this” represent, and are the ‘dragger_position’ and ‘question_number’ variables arbitrarily named by you?

I’ve attempted to inject JS into the prototype and I’m just not getting anything on the GA side.

First check if you’ve got things set up correctly.

  1. You can make this work only if you send your prototype to axure cloud. You can only test it there, not locally (because the plugin won’t be injected locally)
  2. Pageviews should be picked up automatically by GA. Do you see any data, e.g. pageviews, in GA? Remember that it can take up to 24 hours to see something. If not you’re not correctly including your GA code in the plugin or the plugin is not added to all pages.
  3. Do you see something (‘hello’) in the browser console when you add javascript:console.log('hello'); to a button as described in my previous post (this can be done locally btw)

Looks like it was just a matter of time - I was unaware of the potential lag but I’m seeing activity now! Thanks so much!