• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Better way to add Google Analytics "G-" ID to content page?

Community Beginner ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

For years I've been manually inserting the JavaScript code with my Google Universal Analytics (UA-) ID into the HEAD section of the index.html files that Captivate generates.  I made a keyboard macro to type it, but it's still kind of a pain.  A completely automated deploy step would make it easier and less error-prone to push out updates.

 

Now that Google is replacing the UA- numbers with G- numbers, I figure it's a good idea to find out whether there's a better way to do this.  All I really want to do is track traffic to my various e-learning modules in Google Analytics the way I can do with my conventional web pages.

Views

103

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

LATEST

Couple of ideas that I have used over the years with great sucess have been:

  • You can always put the google tracking code in the On Enter->Execute JavaScript of your first slide in your project. I always create a blank starting slide that acts as a project startup and loads some basic JS and etc....while I use actual JS files with longer more advance code in a seperate JS file that loads when CP runs.... (This one is very easy to do manually...or if you use a basic template to start projects, it could already be loaded when starting new projects..)
  • Have your CP project load an external JS file that contains your Google tracking code....I load all sorts of external files to support many advancd projects over the years.....For example one of the long exisiting commands to do so would be placing this line of code into your first CP slide in the On Enter->Execute JavaScript -  $("body").append("<script src='assets/foldername/javaScriptFilename.js'></script");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources