Jump to content


Photo

Adding Google Analytics Code to Published Websites

publish analytics google internet

  • Please log in to reply
4 replies to this topic

#1 smither23

smither23

    New Member

  • Members
  • Pip
  • 1 posts

Posted 03 January 2014 - 11:38 PM

Hi,

I'm wondering if anyone has successfully added the Google Analytics tracking code to websites. I would like to be able to get statistics on who is viewing my family tree, location, etc.

Technically what needs to happen is that we have to add some javascript code to every file.

Thanks.

#2 TomH

TomH

    Advanced Member

  • Members
  • PipPipPip
  • 6111 posts

Posted 04 January 2014 - 12:27 PM

I have enabled Google Analytics only on a Google Site and on a RootsWeb one-page site. To accomplish what you want on a many-page RootsMagic website depends on which type you use:
  • The old, now depecrated, pure HTML website is easyier to achieve. Use a batch, search and replace procedure to modify every HTML page. The old, now unsupported ReplaceText was ideal for this task - http://www.ecobyte.com/replacetext/
  • The new JavaScript powered Publish Online website is trickier, if not impossible. easier but not as informative Iirc, there is only one HTML page, the root (or very few). The rest There are just a half-dozen html files to which you can add the Analytics snippet of Javascript including the templates for Individual details, Pedigree and Family Groupsheet. Specific data to populate these pages are generated on the fly in the browser from Javascript, CSS and XML files. You could add the code to the static pages before uploading. You would need to know JavaScript pretty well to edit the scripts so that the on-the-fly pages contain the Google Analytics code. However, I wonder if the code would even work and whether Analytics would show anything meaningful for anything but the static page. It's an interesting question. I'm interested to know how you did it, if you succeed.

Edited by TomH, 05 January 2014 - 10:57 AM.

Tom user of RM7550 FTM2017 Ancestry.ca FamilySearch.org FindMyPast.com
SQLite_Tools_For_Roots_Magic_in_PR_Celti wiki, exploiting the database in special ways >>> RMtrix-tiny.png app, a bundle of RootsMagic utilities.


#3 TomH

TomH

    Advanced Member

  • Members
  • PipPipPip
  • 6111 posts

Posted 04 January 2014 - 10:43 PM

I had a closer look at the Publish Online website and concluded that you could easily add the tracking code to the half-dozen HTML pages so you should be able to get some info on site visits. However, you cannot track down to the page for a particular individual or for a particular family. There is one master page for individuals and one for group sheets which call javascript queries to populate the pages with the specifics.

I went ahead and tried - first attempt seemed to fail making me think that part of the server-side processing post upload stripped out the tracking code snippet. However, on the second attempt, the snippets are present when I view the source code coming back from my.RootsMagic.com and I now see real time results on Google Analytics. :)

I used PSPad to manually add the snippet to each of the HTML pages, in some cases running its HTML Reformat tool because the page code was compacted and hard to read.

Tom user of RM7550 FTM2017 Ancestry.ca FamilySearch.org FindMyPast.com
SQLite_Tools_For_Roots_Magic_in_PR_Celti wiki, exploiting the database in special ways >>> RMtrix-tiny.png app, a bundle of RootsMagic utilities.


#4 TomH

TomH

    Advanced Member

  • Members
  • PipPipPip
  • 6111 posts

Posted 05 January 2014 - 12:14 PM

To summarize for those unfamiliar with Google Analytics:
  • Analytics is a Google service that tracks usage of a website, giving information about the number of visits, number of unique visitors, how long they visited, number of pages viewed, their location and a host of other data. See http://www.google.com/analytics/
  • You need a Google account to use Google Analytics. Then you set up an account for your website(s) within Analytics.
  • To track a website, you add it your Analytics account which generates a snippet of Javascript containing a unique tracking code that you need to paste into each html page you want tracked on that site.
  • You need to know the URL of your website in order to add the site to your account. For RM's Publish Online, the URL is typically http://my.RootsMagic.com/publishonlineaccountname where publishonlineaccountname is the name you assign in the Publish Online dialog. However, you may not know for certain what the URL is until you complete publishing (uploading) when the RM dialog tells you the URL. So go ahead and Publish but, for convenience and avoidance of having to go through all the steps again in the Publish Online dialog, do not cancel out of Publish Online - having uploaded, as long as you do not cancel out of the dialog, it leaves open the option to re-publish (re-upload) your website files.
  • Having added the website to your Analytics account, you will see the Analytics tracking snippet which you should copy and save to a text file. Don't modify it.
  • Now locate the locally generated website files - earlier in the Publish Online dialog, you will have specified or accepted its default, Open each of the HTML files in its root directory (index, individual, pedigree, groupsheet and, optionally, names and help) with an HTML editor such as PSPad (even a text editor such as Notepad will do) and paste the Analytics snippet between the </head> tag and whatever precedes it. It is helpful to use something like PSPad which can reformat the HTML code so that it is easier to read and to locate the appropriate place. Save the revised files over the original ones.
  • Back to RM's Publish Online and upload the "family information" again. Use its "Check site status" to confirm that processing is 100% completed before browsing the website. Use the browser's "View page source" or equivalent function to confirm that the tracking snippet is on the page.
  • Confirm Analytics is tracking by selecting "All website data" under your Analytics account for this website and viewing Real Time > Overview while alternately browsing your Publish Online website. It displays the last 30 minutes of detected activity.
  • Wait a day to view Analytics Audience > Overview for longer term history of activity that occurred >24 hours earlier.

Tom user of RM7550 FTM2017 Ancestry.ca FamilySearch.org FindMyPast.com
SQLite_Tools_For_Roots_Magic_in_PR_Celti wiki, exploiting the database in special ways >>> RMtrix-tiny.png app, a bundle of RootsMagic utilities.


#5 TomH

TomH

    Advanced Member

  • Members
  • PipPipPip
  • 6111 posts

Posted 14 March 2016 - 02:47 PM

The recent discussion about getting search engines to crawl a RootsMagic published website inspired me to return to an experiment I started with a RM6 Publish Online website back in Jan 2014. I added a Google Analytics code to the HTML files in the local original 'website' root folder before Publish uploaded it to my.RootsMagic.com. Then I sat back and waited but nothing much happened and I forgot about it until now. I just now reviewed the activity and see that there was a surge of sessions over a year later. I don't yet know why. I do not recall taking any special steps to publicize the site; I don't remember if I ever submitted it for indexing. And what is puzzling is that Analytics reports that, by far, the Mac OS and Chrome browser were used to access the site. I would not have expected Chrome to be the dominant browser on Macs. I don't use Mac so my own accesses are among the few on Windows and iOS.

 

Here is a screenshot of a report - a little fuzzy due to scaling but you will get the drift:

RM6_Publish_Online_Website_Analytics.png


Tom user of RM7550 FTM2017 Ancestry.ca FamilySearch.org FindMyPast.com
SQLite_Tools_For_Roots_Magic_in_PR_Celti wiki, exploiting the database in special ways >>> RMtrix-tiny.png app, a bundle of RootsMagic utilities.






Also tagged with one or more of these keywords: publish, analytics, google, internet