Google Analytics multiple tracking and several questions

Please post all questions relating to Help & Manual 6 here!

Moderators: Alexander Halser, Tim Green

Post Reply
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

Hi there.

Does anybody experience multiple Google Analytics requests when someone visit a Webhelp platform generated by HM6.5?
* First request: Absolute URL of a Webhelp
* Second and third request: Filename of a Webhelp topic

Question: Why do we track basename of a .htm topic?
The following code is available in helpman_navigation.js in the track() function:

Code: Select all

      case "topic":
        data = data.substring(data.indexOf("//")+1,data.length);
        data = data.substring(data.lastIndexOf("/")+1,data.length);
        pageTracker._trackPageview(data);
This means that we do not track the absolute path, we track a value provided for _trackPageview function. This may mix GA results in a case of multiple languages or custom builds.

Question: What is the purpose of the track() funcion? It is not enough to set this?

Code: Select all

_gaq.push(["_trackPageview"]);
Question: It is (or will be) possible to customize Google Analytics behavior except of the only setting: Google Analytics code?

Thanks
M.
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Tim Green »

Hi Michal,

Thanks for posting this. I'm having the development team check into it and will get back to you on it when I hear from them.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Alexander Halser »

Hello Michal,

The GA tracking does not track topics twice and certainly not one time with the full url and one time with the page name only. This can only happen if you have enabled both - the built-in GA tracking and custom GA code in the topic template.

H&M tracks the page name only because that's what the GA function _trackPageview() expects. We could include a relative path, but not the full url. H&M not only tracks pageviews, but also full-text searches, clicked index keywords and - if enabled - exit pages (that is, when the reader clicks on an external link to leave the help system, the exit is tracked). Furthermore, if you open a topic page directly, the page view is not tracked. Because in most cases, when a topic is opened directly (outside the navigation frame), it gets synced and reloaded inside the navigation frame. This would indeed cause double tracking and to avoid this, we track the topic only when it's inside the navigation frame.

The tracker function is implemented in the file "helpman_navigation.js":

Code: Select all

function track(action, data) {
  if (gaaccount != "") {	
    if (window._gat) {
      var pageTracker = window._gat._getTracker(gaaccount);
      switch(action) {
      case "topic":
        data = data.substring(data.indexOf("//")+1,data.length);
        data = data.substring(data.lastIndexOf("/")+1,data.length);
        pageTracker._trackPageview(data);
        break;

      case "search":
        pageTracker._trackPageview(data);
        break;

      case "index":
        pageTracker._trackEvent("Help|IndexTerm", data, null, null);
        break;

      case "exit":
        pageTracker._trackEvent("Help|ExitTo", data, null, null);
        break;
      }
    }
  }
}
For detailed information on this function, please see
https://developers.google.com/analytics ... ckPageview
Question: It is (or will be) possible to customize Google Analytics behavior except of the only setting: Google Analytics code?
Yes. You can implement your own GA tracking by simply disabling the built-in implementation in Help & Manual: Open your project, go to "Config > Publishing Options > Webhelp > Google" and remove the Google Analytics Account number. If this setting is empty, H&M will not execute any GA code (without an account number, it cannot anyway). Now you can implement your own GA tracking in the topic HTML template with any functionality you need.
Alexander Halser
Senior Software Architect, EC Software GmbH
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

Thanks Alex for your reply.

It would be good to track a relative URL (without hostname). Now, it's only possible by hardoding the bundled helpman_navigation.js file > _trackPageview() funcion. Of course we are able to implement GA code by ourselves, but we can lose the HM built-in features, such as search tracking, etc.

Let's say we will modify the "data" variable in helpman_navigation.js to track relative URL, but, what about the 3 GA requests after opening index.html of a help page? Does it not make multiple GA results? See the attachment below:
You do not have the required permissions to view the files attached to this post.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Alexander Halser »

Hello Michal,

We've updated the GA tracking script to make absolutely sure that pages are not tracked twice. The script now tests if the page has been tracked before and ignores subsequent tracking attempts. So no matter if the user reloads a topic page or a topic page gets reloaded in the navigation frame, it's never tracked twice.

Here is the update link:
http://news.helpandmanual.com/2014/05/h ... -5-update/
Alexander Halser
Senior Software Architect, EC Software GmbH
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

Alex, that's wonderful that it's fixed and also a great speed! :)
I will try it.

I've also made a few minutes ago several edits to helpman_navigation.js to
- prevent duplicate results
- track relative URL instead of a topic name

Here is the diff for .js file generated in HM 6.5.0 build 2960:
http://www.diffchecker.com/iw1zynkt
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

I see the change which prevents to track duplicate results, but doesn't solve the second part which I've reported.
Reasons why I'm still talking about disatvantages of single page tracking.

If I navigate to Real-Time > Overview in the Google Analytics web interface, I can see the following:
1. A page tracked after someone clicks on a topic in Table of Contents: But without a relative path (orange rectangle)
2. URL tracked after a first visit of a help page: There's also a strange '=' character in the end of URL (red rectangle)

Drawbacks if we track single page only:
- Duplicate results if we have different help pages on a same domain (for example, introduction.htm in 2 different projects)
- Duplicate results in a case of multiple languages (for example, sk-SK/introduction.htm and en-US/introduction.htm)

See also the attached image.
Alex, Any clue?

As I said, the system developed in HM is almost fine-tuned and we do not with to implement our own. If we decide to hardcode .js files, it wouldn't be consistent in future releases of HM.
You do not have the required permissions to view the files attached to this post.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Alexander Halser »

Hello Michal,

That's correct, the script still tracks the page name only. The same GA number cannot be used for multiple help projects/languages. You can modify the script by removing the two lines as you did in your diff. After modification, add the modifed .js to the baggage files list of your help project (or alternatively to the baggage list of the skin you compile your projects with). This will overwrite H&M's version automatically.
Alexander Halser
Senior Software Architect, EC Software GmbH
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

OK, thanks, I understand.

Alex, actiolly, the two lines in original version of helpman_navigation.js are redundant, it seems the functions lazysync() and quicksync() are sending page names only.
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Tim Green »

Hi Michal,

lazysync and quicksync just call the track() function, telling it which action to perform and passing the topic ID as the data parameter. You can modify this to pass any data you want, because that portion is neutral; it is just the string sent to Google Analytics. Just don't change the calling argument of lazysync(), because that requires its single argument to be the topic ID to synchronize the TOC correctly.

You only need to change the data passed to track in lazysync, or in the track() function itself, because it is only called via lazysync (also in the Premium Pack skins, where it also needs to be called for loading topics into tabs and switching tabs). QuickSync() is actually never called at all, that is a legacy function from earlier versions of the program that synchronized the TOC on the basis of a specific code. However, it was found that the speed difference between that and locating the href value directly was negligible, so we stopped using it.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

Thanks Tim for the more specific informatou about such funcions.
I changed the .js file before your answer and it's working correctly now.

Have you been experiencing tracking of "about:blank" pages? We do. This happens when an external page is called outside our help (in a new tab/window). Don't know why. This modification in helpman_settings.js prevents tracking of blank pages:

Code: Select all

if ((window._gat) && (lastTrackEvent != action+data) && data.indexOf(":blank") < 0) {
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Tim Green »

Hi Michal,
michal_novomesky wrote:Have you been experiencing tracking of "about:blank" pages? We do. This happens when an external page is called outside our help (in a new tab/window).
How are you calling the external page? And is the new tab an internal tab in a Premium Pack webhelp skin or a real additional browser tab?
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

Hi Tim,

It's not a premium pack, it's a modified variant of a standard webhelp skin. The generated content in .htm looks like:

Code: Select all

<a href="http://url.url" target="_blank" onclick="return HMTrackTopiclink(this);" class="weblink">Some content</a>
Google Analytics has tracked the following:

Code: Select all

BASEURL/about:blank
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by Alexander Halser »

No.
It tracks literally "Help|ExitTo", "http://url.url/".

Please include an alert into the script to test it yourself.
Alexander Halser
Senior Software Architect, EC Software GmbH
michal_novomesky
Posts: 51
Joined: Thu Jan 12, 2012 2:21 pm
Contact:

Re: Google Analytics multiple tracking and several questions

Unread post by michal_novomesky »

I don't have a time to debug. Let's leave this "about:blank" problem unsolved for now. We will see if someone else will experience such similar problem.
Post Reply