<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.socialstack.dev/index.php?action=history&amp;feed=atom&amp;title=Google_Analytics</id>
	<title>Google Analytics - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.socialstack.dev/index.php?action=history&amp;feed=atom&amp;title=Google_Analytics"/>
	<link rel="alternate" type="text/html" href="https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;action=history"/>
	<updated>2026-10-16T06:35:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;diff=449&amp;oldid=prev</id>
		<title>Luke at 20:42, 7 February 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;diff=449&amp;oldid=prev"/>
		<updated>2023-02-07T20:42:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:42, 7 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;At this point with the config saved, your site should be communicating with Google Analytics. It is not yet compliant with global laws though so do continue reading on for more about that to see if it is relevant to you.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;At this point with the config saved, your site should be communicating with Google Analytics. It is not yet compliant with global laws though so do continue reading on for more about that to see if it is relevant to you.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Future note: The configuration for Google Analytics along with handling the cookie banner below may end up being unified in the installable Api/GoogleAnalytics. The above, however, will always work provided Google still supports it of course.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Page views =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Page views =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Luke</name></author>
	</entry>
	<entry>
		<id>https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;diff=444&amp;oldid=prev</id>
		<title>Luke at 20:20, 7 February 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;diff=444&amp;oldid=prev"/>
		<updated>2023-02-07T20:20:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:20, 7 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[&lt;/del&gt;[https://analytics.google.com/analytics/web/ Google Analytics&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]&lt;/del&gt;] is a service which can be dropped on a site to give you more insights about your visitors. Socialstack has some convenience mechanisms to get you started quickly and also to help you be fully compliant with global privacy laws.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[https://analytics.google.com/analytics/web/ Google Analytics] is a service which can be dropped on a site to give you more insights about your visitors. Socialstack has some convenience mechanisms to get you started quickly and also to help you be fully compliant with global privacy laws.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;First, you&amp;#039;ll need to setup an account on &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[&lt;/del&gt;[https://analytics.google.com/analytics/web/ Google Analytics&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]&lt;/del&gt;]. Doing this will give you a measurement ID which you&amp;#039;ll need to drop in to the configuration of your site to get it communicating with Google Analytics. GA wants it to be at the start of the head tag of your site so specifically that means it goes in the HtmlService config and in &amp;quot;StartHeadScripts&amp;quot;. Note that MEASUREMENT_ID_HERE is present twice:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;First, you&amp;#039;ll need to setup an account on [https://analytics.google.com/analytics/web/ Google Analytics]. Doing this will give you a measurement ID which you&amp;#039;ll need to drop in to the configuration of your site to get it communicating with Google Analytics. GA wants it to be at the start of the head tag of your site so specifically that means it goes in the HtmlService config and in &amp;quot;StartHeadScripts&amp;quot;. Note that MEASUREMENT_ID_HERE is present twice:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Luke</name></author>
	</entry>
	<entry>
		<id>https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;diff=443&amp;oldid=prev</id>
		<title>Luke: Created page with &quot;https://analytics.google.com/analytics/web/ Google Analytics is a service which can be dropped on a site to give you more insights about your visitors. Socialstack has som...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.socialstack.dev/index.php?title=Google_Analytics&amp;diff=443&amp;oldid=prev"/>
		<updated>2023-02-07T20:20:17Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=Https://analytics.google.com/analytics/web/_Google_Analytics&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Https://analytics.google.com/analytics/web/ Google Analytics (page does not exist)&quot;&gt;https://analytics.google.com/analytics/web/ Google Analytics&lt;/a&gt; is a service which can be dropped on a site to give you more insights about your visitors. Socialstack has som...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[https://analytics.google.com/analytics/web/ Google Analytics]] is a service which can be dropped on a site to give you more insights about your visitors. Socialstack has some convenience mechanisms to get you started quickly and also to help you be fully compliant with global privacy laws.&lt;br /&gt;
&lt;br /&gt;
First, you&amp;#039;ll need to setup an account on [[https://analytics.google.com/analytics/web/ Google Analytics]]. Doing this will give you a measurement ID which you&amp;#039;ll need to drop in to the configuration of your site to get it communicating with Google Analytics. GA wants it to be at the start of the head tag of your site so specifically that means it goes in the HtmlService config and in &amp;quot;StartHeadScripts&amp;quot;. Note that MEASUREMENT_ID_HERE is present twice:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;StartHeadScripts&amp;quot;:[&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;type&amp;quot;: &amp;quot;text/javascript&amp;quot;,&lt;br /&gt;
&amp;quot;src&amp;quot;: &amp;quot;https://www.googletagmanager.com/gtag/js?id=MEASUREMENT_ID_HERE&amp;quot;,&lt;br /&gt;
&amp;quot;async&amp;quot;: true&lt;br /&gt;
},&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;type&amp;quot;: &amp;quot;text/javascript&amp;quot;,&lt;br /&gt;
&amp;quot;content&amp;quot;: &amp;quot;window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag(&amp;#039;js&amp;#039;, new Date());gtag(&amp;#039;config&amp;#039;, &amp;#039;MEASUREMENT_ID_HERE&amp;#039;);&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point with the config saved, your site should be communicating with Google Analytics. It is not yet compliant with global laws though so do continue reading on for more about that to see if it is relevant to you.&lt;br /&gt;
&lt;br /&gt;
= Page views =&lt;br /&gt;
&lt;br /&gt;
To get all page views sent to Google Analytics, install the page load event handler:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
socialstack i UI/Functions/GaPageChange&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This module simply needs to exist in your project for the event to be handled. Because many page changes on a Socialstack site don&amp;#039;t result in the entire page being loaded, this module makes sure all of the faster page changes are captured too.&lt;br /&gt;
&lt;br /&gt;
= Global privacy laws =&lt;br /&gt;
&lt;br /&gt;
Because you&amp;#039;re adding third party tracking to your site, you&amp;#039;ll need to add a cookie prompt and slightly edit the previous config if you want the site to be compliant with EU, UK and California law. A simple built in cookie prompt is available under the following module:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
socialstack i UI/CookieConsent&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should then use this &amp;lt;CookieConsent&amp;gt; module by dropping it in the footer of your site, such that it is rendered on the frontend. It defaults to describing the contents of a Socialstack site as well as Google Analytics. Once it&amp;#039;s added to the site, you&amp;#039;ll need to ensure that Google Analytics honours the request of the user from this UI. That results in the config looking like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;StartHeadScripts&amp;quot;:[&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;type&amp;quot;: &amp;quot;text/javascript&amp;quot;,&lt;br /&gt;
&amp;quot;src&amp;quot;: &amp;quot;https://www.googletagmanager.com/gtag/js?id=MEASUREMENT_ID_HERE&amp;quot;,&lt;br /&gt;
&amp;quot;async&amp;quot;: true&lt;br /&gt;
},&lt;br /&gt;
{&lt;br /&gt;
&amp;quot;type&amp;quot;: &amp;quot;text/javascript&amp;quot;,&lt;br /&gt;
&amp;quot;content&amp;quot;: &amp;quot;window.cookieLayer=window.cookieLayer||[];window.cookieLayer.push((s)=&amp;gt;{if(s.all){window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag(&amp;#039;js&amp;#039;, new Date());gtag(&amp;#039;config&amp;#039;, &amp;#039;MEASUREMENT_ID_HERE&amp;#039;);}})&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above config will mean if the user accepts all cookies on the prompt then Google Analytics will be activated.&lt;/div&gt;</summary>
		<author><name>Luke</name></author>
	</entry>
</feed>