<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Digital Insanity Magazine by Bruno Amaral</title>
		<link>https://brunoamaral.eu/tags/google-analytics/</link>
		<description>The creative escape of Bruno Amaral</description>
		<generator>Hugo -- gohugo.io</generator>
		<language>en-us</language>
		<copyright>Bruno Amaral 2019</copyright>
		<lastBuildDate>Fri, 18 Jan 2019 12:29:43 +0000</lastBuildDate>
		<image>
			<url>https://brunoamaral.eu/static/logo_blue_small.png</url>
			<title>Digital Insanity Magazine</title>
			<link>https://brunoamaral.eu/tags/google-analytics/</link>
		</image>
		
		<atom:link href="https://brunoamaral.eu/tags/google-analytics/index.xml" rel="self" type="application/rss+xml" />
		
		
		<item>
			<title>One Analytics to Rule Them All</title>
			<link>https://brunoamaral.eu/post/one-analytics-to-rule-them-all/</link>
			<pubDate>Fri, 18 Jan 2019 12:29:43 +0000</pubDate>
			
			<guid>https://brunoamaral.eu/post/one-analytics-to-rule-them-all/</guid>
			<description>
				
				
				
				<![CDATA[<img src="https://brunoamaral.eu/post/one-analytics-to-rule-them-all/images/henri-l-547224-unsplash_export_hucccded5e8408b5fce38cef680d85c488_247319_640x0_resize_q85_lanczos.jpg" width="640" height="427"/>]]>
				
				


	

&lt;a style=&#34;background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &amp;quot;San Francisco&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Ubuntu, Roboto, Noto, &amp;quot;Segoe UI&amp;quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px&#34; href=&#34;https://unsplash.com/photos/CHt4BMi0-Is&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34; title=&#34;Photo by Henri L.&#34;&gt;&lt;span style=&#34;display:inline-block;padding:2px 3px&#34;&gt;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; style=&#34;height:12px;width:auto;position:relative;vertical-align:middle;top:-1px;fill:white&#34; viewBox=&#34;0 0 32 32&#34;&gt;&lt;title&gt;Unsplash Logo&lt;/title&gt;&lt;path d=&#34;M20.8 18.1c0 2.7-2.2 4.8-4.8 4.8s-4.8-2.1-4.8-4.8c0-2.7 2.2-4.8 4.8-4.8 2.7.1 4.8 2.2 4.8 4.8zm11.2-7.4v14.9c0 2.3-1.9 4.3-4.3 4.3h-23.4c-2.4 0-4.3-1.9-4.3-4.3v-15c0-2.3 1.9-4.3 4.3-4.3h3.7l.8-2.3c.4-1.1 1.7-2 2.9-2h8.6c1.2 0 2.5.9 2.9 2l.8 2.4h3.7c2.4 0 4.3 1.9 4.3 4.3zm-8.6 7.5c0-4.1-3.3-7.5-7.5-7.5-4.1 0-7.5 3.4-7.5 7.5s3.3 7.5 7.5 7.5c4.2-.1 7.5-3.4 7.5-7.5z&#34;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/span&gt;&lt;span style=&#34;display:inline-block;padding:2px 3px&#34;&gt;Henri L.&lt;/span&gt;&lt;/a&gt;
&lt;p&gt;The notes below apply if you run a small web design studio that needs to assure a good level of service to your clients with the most efficiency.&lt;/p&gt;
&lt;p&gt;This means cutting down repetitvie tasks, like setting up a Google Analytics Account for every website a client needs.&lt;/p&gt;
&lt;h3 class=&#34;title&#34;&gt;Google Analytics&lt;/h3&gt;
&lt;p&gt;To begin, we need some configuration on Google Analytics, later we will tie it all down with Nginx.&lt;/p&gt;
&lt;h4 class=&#34;title&#34;&gt;Step One, Setting up a Google Analytics Account and Property&lt;/h4&gt;
&lt;p&gt;Pretty self explanatory really. Just set up an account, let&amp;rsquo;s call it &lt;strong&gt;StudioX&lt;/strong&gt; and create a property called &lt;strong&gt;Client 1&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The property&amp;rsquo;s settings can be whatever you wish, just make sure that the default URL is real.&lt;/p&gt;
&lt;p&gt;Step by step instructions to set up the Account and property are available here: https://support.google.com/analytics/answer/1008015?hl=en&lt;/p&gt;
&lt;p&gt;Grab the tracking code and ID, we will need it later. It&amp;rsquo;s something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!-- Global site tag (gtag.js) - Google Analytics --&amp;gt;
&amp;lt;script async src=&amp;quot;https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-XX&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag(&#39;js&#39;, new Date());

  gtag(&#39;config&#39;, &#39;UA-XXXXXXXX-XX&#39;);
&amp;lt;/script&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;h4 class=&#34;title&#34;&gt;Step Two, One View for each Website&lt;/h4&gt;
&lt;p&gt;Let&amp;rsquo;s imagine &lt;strong&gt;Client 1&lt;/strong&gt; owns 2 websites that you have created, we will need to setup a data view for each of them.&lt;/p&gt;
&lt;p&gt;At the view level you can set a new &lt;strong&gt;Default URL&lt;/strong&gt;, and you can also set a switch for &lt;strong&gt;Bot filtering&lt;/strong&gt; that removes the known bots to from your reports.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/view-settings.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h4 class=&#34;title&#34;&gt;Step Three, Filter by hostname&lt;/h4&gt;
&lt;p&gt;This is straightforward, add a new filter to you view so that it only shows the hostname of the website we want to track.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;images/filter-setup.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;h3 class=&#34;title&#34;&gt;Nginx&lt;/h3&gt;
&lt;p&gt;I was looking out for a way to use a main Google Analytics Account in all websites I host, and found this gist by &lt;a href=&#34;https://twitter.com/JakubJirutka&#34;&gt;Jakub Jirutka&lt;/a&gt;&lt;/p&gt;
&lt;script type=&#34;application/javascript&#34; src=&#34;https://gist.github.com/jirutka/5279057.js&#34;&gt;&lt;/script&gt;

&lt;p&gt;https://gist.github.com/jirutka/5279057&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s quite simple, in every website hosted by Nginx, it will replace the &lt;code&gt;&amp;lt;/head&amp;gt;&lt;/code&gt; tag for the google analytics code we had previously. After that&amp;rsquo;s done, we just include the analytics.conf file in the server block of our website.&lt;/p&gt;
&lt;p&gt;What is below is an example, &lt;strong&gt;don&amp;rsquo;t just copy and paste it to your config&lt;/strong&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;server {

  listen 80;
  listen 443 ssl;
  server_name www.WEBSITE1.com WEBSITE1.com;
  include incl/analytics.conf;

  # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
  ssl_certificate /etc/letsencrypt/live/WEBSITE1.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/WEBSITE1.com/privkey.pem;
  ssl_trusted_certificate /etc/letsencrypt/live/WEBSITE1.com/fullchain.pem;
  ssl_session_timeout 1d;
  ssl_session_cache shared:SSL:50m;

  # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
  ssl_dhparam /etc/nginx/ssl/dhparam.pem;

  # modern configuration. tweak to your needs.
  ssl_protocols TLSv1.1 TLSv1.2;
  ssl_ciphers &#39;YOUR CYPHERS GO HERE&#39;;
  ssl_prefer_server_ciphers on;

  # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
  add_header Strict-Transport-Security max-age=15768000;

  # OCSP Stapling ---
  # fetch OCSP records from URL in ssl_certificate and cache them
  ssl_stapling on;
  ssl_stapling_verify on;

  root /var/web/WEBSITE1.com;
  index index.php index.html index.htm;


  location / {

    # try_files $uri $uri/ =404;
    try_files $uri $uri/ /index.php?q=$uri&amp;amp;$args;
  }


  # lets allow .wellknown challenge to pass so we can have https
  location /.well-known {
    allow all;
    auth_basic off;
  }

  error_page 404 /404.html;

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {

    root /usr/share/nginx/html;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 class=&#34;title&#34;&gt;Day to day&lt;/h2&gt;
&lt;p&gt;From now on, each time you need to track analytics for a new website that belongs to &lt;strong&gt;Client1&lt;/strong&gt;, just add a new view, change the Default URL and setup the filter to only track traffic to that hostname.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s two steps in Google Analytics, instead of three in your Content Management System (CMS) and Analytics Account.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Setting up a new property&lt;/li&gt;
&lt;li&gt;Installing the tracking code in the CMS&lt;/li&gt;
&lt;li&gt;Setting up a new view&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I haven&amp;rsquo;t tested, but in theory you can setup your View after the site goes live. Your data should already be there because the Google Analytics Property was already collecting information, it just wasn&amp;rsquo;t filtering by hostname.&lt;/p&gt;
&lt;p&gt;You can also create different &lt;code&gt;analytics.conf&lt;/code&gt; files, one for each Client/Property you want to use. Something like &lt;code&gt;analytics.client1.conf&lt;/code&gt;, &lt;code&gt;analytics.client2.conf&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;There is one small caveat, with this implementation you can only track 25 websites for that Property.&lt;/p&gt;
&lt;p&gt;You can take it one step further by using the Google Tag Manager code. It&amp;rsquo;s the same procedure and you gain the hability to setup new events across all sites. Within Google Tag Manager you can also fire the analytics code, but that would be a matter for another article.&lt;/p&gt;
&lt;p&gt;Feel free to leave a comment if you find something you would like to add.&lt;/p&gt;

			</description>
		</item>
		
		<item>
			<title>Content Groups in Hugo</title>
			<link>https://brunoamaral.eu/post/content-groups-in-hugo/</link>
			<pubDate>Sat, 03 Mar 2018 00:41:57 +0000</pubDate>
			
			<guid>https://brunoamaral.eu/post/content-groups-in-hugo/</guid>
			<description>
				
				
				
				<![CDATA[<img src="https://brunoamaral.eu/post/content-groups-in-hugo/images/gohugo_hua0d4d4b24f4da3a102e4452ac738b95f_41002_640x0_resize_q85_lanczos.jpg" width="640" height="148"/>]]>
				
				&lt;p&gt;If you are not a webdesigner or programmer, you probably want to skip this post. Click on &lt;a href=&#34;https://brunoamaral.eu/categories/&#34;&gt;https://brunoamaral.eu/categories/&lt;/a&gt; to find something that is more worthy of your time.&lt;/p&gt;
&lt;p&gt;For everyone else, a little background first. My this blog is built using &lt;a href=&#34;https://gohugo.io/&#34;&gt;Hugo&lt;/a&gt; and has the following sections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Posts&lt;/li&gt;
&lt;li&gt;Pages&lt;/li&gt;
&lt;li&gt;Stories&lt;/li&gt;
&lt;li&gt;Instagrams&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And I wanted to track these elements as &lt;a href=&#34;https://support.google.com/analytics/answer/2853423?hl=en&#34;&gt;content groups in Google Analytics&lt;/a&gt;, using Google Tag Manager. Because I am not at all sure which of these drives more traffic and interest to the site.&lt;/p&gt;
&lt;p&gt;You can configure 5 levels of content groups, and I wanted to configure the following:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Posts&lt;/th&gt;
&lt;th&gt;Pages&lt;/th&gt;
&lt;th&gt;Stories (Section)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Index 1&lt;/td&gt;
&lt;td&gt;Post&lt;/td&gt;
&lt;td&gt;Page&lt;/td&gt;
&lt;td&gt;Stories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Index 2&lt;/td&gt;
&lt;td&gt;nil&lt;/td&gt;
&lt;td&gt;nil&lt;/td&gt;
&lt;td&gt;StoryName&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Index 3&lt;/td&gt;
&lt;td&gt;PostTitle&lt;/td&gt;
&lt;td&gt;PageTitle&lt;/td&gt;
&lt;td&gt;StoryArticleTitle&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&#34;configure-your-hugo-theme&#34;&gt;Configure your Hugo theme&lt;/h3&gt;
&lt;p&gt;To get this information out of &lt;a href=&#34;https://gohugo.io/&#34;&gt;Hugo&lt;/a&gt; do this, I used the classes in the &lt;code&gt;body&lt;/code&gt; tag.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;_default/single.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;body&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;single contentgrouptype-{{ .Section }} contentgroupname-{{ with .Params.stories }}{{ index . 0 | urlize }}{{ end }} article article-title-{{ .Title |urlize }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;_default/page.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;body&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;single page contentgrouptype-{{ .Section }} contentgroupname-{{ .Title | urlize }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Since the page for Instagrams has its own layout, I took advantage of that:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Instagrams/instagram.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;body&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;single instagram contentgrouptype-instagrams contentgroupname-{{ .URL }}&amp;#34;&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;id&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;instagram&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;I should be using the title of the instragram post, with urlize. The reason I am not, is because my script still does not collect that information.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;taxonomy/category.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;body&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;page contentgrouptype-category contentgroupname-{{ .Title | urlize }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;taxonomy/story.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;body&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;page subhomepage contentgrouptype-story contentgroupname-{{ .Params.story_title | urlize }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;taxonomy/tag.html&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;body&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;class&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;page contentgrouptype-tag contentgroupname-{{ .Title | urlize }}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;configure-google-tag-manager&#34;&gt;Configure Google Tag Manager&lt;/h3&gt;
&lt;p&gt;First, we need to install Google Analytics from the Google Tag Manager &lt;strong&gt;tag&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://brunoamaral.eu/post/content-groups-in-hugo/images/google-tag-manager.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;What you are seeing in &lt;strong&gt;{{ }}&lt;/strong&gt; are variables that we need to create and configure to tie this together.&lt;/p&gt;
&lt;p&gt;In Google Tag Manager, click on &amp;ldquo;Variables&amp;rdquo; and then &amp;ldquo;New&amp;rdquo;. Select &amp;ldquo;Page Variables&amp;rdquo; &amp;gt; &amp;ldquo;Custom Javascript&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Then use this code for the variable &amp;ldquo;Content Group Type&amp;rdquo;, which will have a value of &amp;ldquo;tag&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;category&lt;/li&gt;
&lt;li&gt;stories&amp;rdquo;, or &amp;ldquo;instagrams&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Identify if content group is a tag, category, story etc.
&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(){&lt;/span&gt;
&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupclass&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;document&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;body&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;classList&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
 &lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;dem&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
 &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;dem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;contentgroupclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;match&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;contentgrouptype-&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
      &lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroup&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;replace&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;sr&#34;&gt;/contentgrouptype-/g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
 &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code for &amp;ldquo;Content Group Name&amp;rdquo; will follow the same structure:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(){&lt;/span&gt;
&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupnameclass&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;document&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;body&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;classList&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
 &lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;dem&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupnameclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
 &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;dem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;contentgroupnameclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;match&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;contentgroupname-&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
      &lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupname&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupnameclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;replace&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;sr&#34;&gt;/contentgroupname-/g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;contentgroupname&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
 &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And finaly, the code for &amp;ldquo;Content Group Article Title&amp;rdquo;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(){&lt;/span&gt;
&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;articletitleclass&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;document&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;body&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;classList&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
 &lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;dem&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;articletitleclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
 &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;dem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;articletitleclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;match&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;article-title-&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
      &lt;span class=&#34;kd&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;articletitle&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;articletitleclass&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;i&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;replace&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;sr&#34;&gt;/article-title-/g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;articletitle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
      &lt;span class=&#34;k&#34;&gt;break&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
 &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You are done.&lt;/p&gt;
&lt;p&gt;Go to the preview of tag manager and check that it&amp;rsquo;s working in the different pages. Soon, you will begin to see this data arrive in Google Analytics&lt;/p&gt;
&lt;h3 id=&#34;custom-report&#34;&gt;Custom Report&lt;/h3&gt;
&lt;p&gt;For my use case, I prepared a small custom report using the drilldown of the different content groups:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://brunoamaral.eu/post/content-groups-in-hugo/images/google-custom-report.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;And this in turn gives you this report:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://brunoamaral.eu/post/content-groups-in-hugo/images/google-custom-report-content-groups.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;And that&amp;rsquo;s it, you can now use the new Content Groups to see where your readers see the most value.&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;style&gt;
/* Background */ .chroma { color: #f8f8f2; background-color: #272822 }
/* Error */ .chroma .err { color: #960050; background-color: #1e0010 }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; }
/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc }
/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; display: block; }
/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; }
/* Keyword */ .chroma .k { color: #66d9ef }
/* KeywordConstant */ .chroma .kc { color: #66d9ef }
/* KeywordDeclaration */ .chroma .kd { color: #66d9ef }
/* KeywordNamespace */ .chroma .kn { color: #f92672 }
/* KeywordPseudo */ .chroma .kp { color: #66d9ef }
/* KeywordReserved */ .chroma .kr { color: #66d9ef }
/* KeywordType */ .chroma .kt { color: #66d9ef }
/* NameAttribute */ .chroma .na { color: #a6e22e }
/* NameClass */ .chroma .nc { color: #a6e22e }
/* NameConstant */ .chroma .no { color: #66d9ef }
/* NameDecorator */ .chroma .nd { color: #a6e22e }
/* NameException */ .chroma .ne { color: #a6e22e }
/* NameFunction */ .chroma .nf { color: #a6e22e }
/* NameOther */ .chroma .nx { color: #a6e22e }
/* NameTag */ .chroma .nt { color: #f92672 }
/* Literal */ .chroma .l { color: #ae81ff }
/* LiteralDate */ .chroma .ld { color: #e6db74 }
/* LiteralString */ .chroma .s { color: #e6db74 }
/* LiteralStringAffix */ .chroma .sa { color: #e6db74 }
/* LiteralStringBacktick */ .chroma .sb { color: #e6db74 }
/* LiteralStringChar */ .chroma .sc { color: #e6db74 }
/* LiteralStringDelimiter */ .chroma .dl { color: #e6db74 }
/* LiteralStringDoc */ .chroma .sd { color: #e6db74 }
/* LiteralStringDouble */ .chroma .s2 { color: #e6db74 }
/* LiteralStringEscape */ .chroma .se { color: #ae81ff }
/* LiteralStringHeredoc */ .chroma .sh { color: #e6db74 }
/* LiteralStringInterpol */ .chroma .si { color: #e6db74 }
/* LiteralStringOther */ .chroma .sx { color: #e6db74 }
/* LiteralStringRegex */ .chroma .sr { color: #e6db74 }
/* LiteralStringSingle */ .chroma .s1 { color: #e6db74 }
/* LiteralStringSymbol */ .chroma .ss { color: #e6db74 }
/* LiteralNumber */ .chroma .m { color: #ae81ff }
/* LiteralNumberBin */ .chroma .mb { color: #ae81ff }
/* LiteralNumberFloat */ .chroma .mf { color: #ae81ff }
/* LiteralNumberHex */ .chroma .mh { color: #ae81ff }
/* LiteralNumberInteger */ .chroma .mi { color: #ae81ff }
/* LiteralNumberIntegerLong */ .chroma .il { color: #ae81ff }
/* LiteralNumberOct */ .chroma .mo { color: #ae81ff }
/* Operator */ .chroma .o { color: #f92672 }
/* OperatorWord */ .chroma .ow { color: #f92672 }
/* Comment */ .chroma .c { color: #75715e }
/* CommentHashbang */ .chroma .ch { color: #75715e }
/* CommentMultiline */ .chroma .cm { color: #75715e }
/* CommentSingle */ .chroma .c1 { color: #75715e }
/* CommentSpecial */ .chroma .cs { color: #75715e }
/* CommentPreproc */ .chroma .cp { color: #75715e }
/* CommentPreprocFile */ .chroma .cpf { color: #75715e }
/* GenericDeleted */ .chroma .gd { color: #f92672 }
/* GenericEmph */ .chroma .ge { font-style: italic }
/* GenericInserted */ .chroma .gi { color: #a6e22e }
/* GenericStrong */ .chroma .gs { font-weight: bold }
/* GenericSubheading */ .chroma .gu { color: #75715e }
&lt;/style&gt;

			</description>
		</item>
		
	</channel>
</rss>