Google analytics

On my Freeway site I have a Google Analytic code on each page to record the number of visitors. Is it possible to do the same to my Xway master page or individual pages yet so it will copy to all the new and current pages I have made? is it a mark-up item and what do I do?

Hi David,

Google analytics is added by a Page Action in Freeway, so this is something you should be able to do using Page Markup in Xway. To add page markup:

  1. Open the Generic Markup section in the Page inspector
  2. Paste markup into the Before </head> section

Doing this on a master page sounds right to me. I don’t know the details of what markup you need to add (except that it involves a Google tracking number), but I can look into this on Monday if no-one else has replied before then.

Thanks Jeremy for that speedy response. I almost got there before you answered in that I pasted it in the CSS mark up but have now deleted that and put it in the Generic Mark up. Below is what I have put in: (I cannot get the lead in/end ‘script’ to appear below i.e script with <> around it for some reason.)

(function(i,s,o,g,r.a,mXi[‘GoogleAnalyticsObject)=ri(r]eitr||function(y
(r).q=(r).q|ld).push(arguments)›,.(r).|=1new Date(;a=s.createElement(o),
m=s.getElementsByTagName(o)(OJ;a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
›window,document,‘script,#/www.google-analytics.com/analytics.js’,/ga’);
ga(‘create’, xxxxxxxxxxxxx.org.uk’);
ga(‘send’, 'pageview");

(function(i,s,o,g,r.a,mXi['GoogleAnalyticsObject)=ri(r]eitr||function(y
(r).q=(r).q|ld).push(arguments)›,.(r).|=1
new Date(;a=s.createElement(o),
m=s.getElementsByTagName(o)(OJ;a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
›window,document,‘script,#/www.google-analytics.com/analytics.js’,/ga’);
ga(‘create’, ‘UA-xxxxxxxx’, ‘xxxxxxxxxxx.org.uk’);
ga(‘send’, 'pageview");

I have taken the numbers out.

I noticed when I pasted the instruction into Generic Markup the lead in < was replaced with " so I changed it to < I hope that is correct?

There are some instructions here:

The markup does need to be enclosed in tags. I don’t know why these are being removed or changed in your document (that doesn’t happen for me). Also, unless this is something Discourse has done, the script should contain straight quotes (') rather than curly quotes (‘’).

Thanks for that Jeremy, however I am rather confused.

Looking at the article you attached headed ’ The Google Analytics tag’ it says ‘The Google Analytics tag should be added near the top of the <head> tag and before any other script or CSS tags, and add the property ID of the Google Analytics property you wish to work with’. Not the Before section you mentioned. On the Xway drop down menu these are two different things.

However, looking at my account on Google Analytics for website tracking it says:

So I am confused as to which I should use. Presumably adding this to the master this is added to each page or is it? I can see myself going wrong on this as I think I am at the boundary of understanding!

Generally, Before </head> is a good place to add markup - but since Google say to add this near the top of the <head> section, the corresponding place in Xway’s Generic Markup section is After <head>

Adding it to the master page will cause it to be inserted on each instance page, so long as the Use Master Generic Markup checkbox is turned on (on each instance page). This should be the case by default.

1 Like

Thanks again Jeremy. Pleased I wasn’t that far off beam so must be pushing the boundary!