11

My web site is posted in English. I do not have the Google Translate plugin installed, nor do I have any plans to install it. However, I'm inferring from some of my analytics data that people visiting my web site are using Google Translate to translate my pages. I presume they're visiting my site and seeing Google's "This page is in English. Would you like to translate it to [their language]?" and clicking "Translate".

Is there any hook in Google's automatic translation, e.g. some event fired, that I can use to detect these automatic translations and fire a Google Analytics event tracking the translation and hopefully capturing the language they're translating to? Note: I've seen this post, but the answer refers to the plugin, which I'm not using. I want to track when Google volunteers to translate automatically.

2

The Google Translate Toolbar only appears to send analytics events for the old (non-universal) analytics. I developed the following workaround. Just:

  1. Ensure you set gaTrack: true and gaId: 'xxx' in your translation toolbar settings
  2. Include the below script on your page alongside the translate snippet

    /*!
     * Capture Analytics for Google Translate
     * As of 2016, the Google Translate toolbar still only works with the old-style analytics (ga.js)
     * The code below mocks the old analytics object, captures the events and passes them to the new Universal Analytics (analytics.js)
     *
     * Source: http://webmasters.stackexchange.com/a/101787/18749
     * Copyright (c) Simon East 2016, for yump.com.au
     * Free to use under MIT licence <https://opensource.org/licenses/MIT>
     */
    window._gaq = {}; window._gat = {};
    window._gat._getTracker = window._gat._getTrackerByName = function(){ return {
      _trackEvent: function(eventCategory, eventAction, eventLabel) {
        // [0] will send the event to the first analytics ID on the page (in case you have multiple)
        if (window.ga && ga.getAll()[0]) {
          ga.getAll()[0].send('event', eventCategory, eventAction, eventLabel);
          window.console && console.log('Translation event sent to Google Analytics:', eventCategory, eventAction, eventLabel);
        } else {
          window.console && console.warn('Could not locate Google Analytics when attempting to log translation events.')
        }
      }
    }}
    
1

I'm not finished with this yet as I'm sure we'll be able to get this set up as event tracking eventually but here is one way that may help/give you what you want for now...

In Google Analytics:-

Audience > Geo > Language

  • Primary Dimension: Language
  • Secondary Dimension: Hostname

Select advanced filter and set this to include hostname translate.googleusercontent.com like the below screenshot demonstrates:-

Filtering Google Translate languages in Google Analytics

This will then show you all instances where Google Translate has been used to translate content on your website along with their detected language.

  • This is super helpful. Thanks! I still wish Google translate would trigger a Javascript event so I could catch it and trigger my own custom Analytics event. But this at least gives me some data to start with. Thanks again! – JB Christy Jan 28 '14 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.