{"id":926,"date":"2016-07-14T10:04:15","date_gmt":"2016-07-14T08:04:15","guid":{"rendered":"http:\/\/blog.thecodecampus.de\/?p=926"},"modified":"2023-12-20T20:21:56","modified_gmt":"2023-12-20T19:21:56","slug":"angular-2-google-analytics-google-tag-manager","status":"publish","type":"post","link":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/","title":{"rendered":"Angular 2: Set up Google Analytics and Google Tag Manager"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">There are many modules to include Google Analytics into your Angular 2 project. But actually this overhead is not really required since a plain implementation is only a few lines of code. So you can spare extra modules.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I highly recommend you to use Google Tag Manager in order to place the tracking information on your site since it allows you to have a professional workflow. Beyond that you can enjoy the advantages of having a versioned history of your changes. Additional many things are way more easier with Google Tag Manager, for example to implement a simple cookie opt-out that affects all implemented tracking codes. <strong>If you don&#8217;t want to use Google Tag Manger see the code at the end of this article.<\/strong><\/span><\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/angularjs-1-set-google-analytics-google-tag-manager\/\" target=\"_blank\" rel=\"noopener noreferrer\">? Tutorial for <strong>Google Analytics with AngularJS 1<\/strong><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Recently we had to implement Analytics on our new site for our German TypeScript User Group ( <a href=\"https:\/\/www.typescriptusers.de\/\">https:\/\/www.typescriptusers.de<\/a>\u00a0). The first step is to create Account and a Container on Google Tag Manager ( <\/span><a href=\"https:\/\/tagmanager.google.com\"><span style=\"font-weight: 400;\">tagmanager.google.com<\/span><\/a><span style=\"font-weight: 400;\"> ).<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-935\" src=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png\" alt=\"GTM1\" width=\"754\" height=\"772\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM1.png 754w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM1-293x300.png 293w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">On confirm you will receive the tracking snippet that you should place on in your index.html. Since we rely on this code in execution time it is required that you place the code directly under the the opening &lt;body&gt; tag of your HTML File. It is recommended to place your custom javascript files after the implementation of GTM or use defer attribute on the script tags.<br \/>\n<\/span>Once you have added the code to your site it is time for the first publish of your empty container. Until you publish your Tag Manager snippet will only cause an loading error. Use the publish Button on the upper right corner of GTM.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-934\" src=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM2.png\" alt=\"GTM2\" width=\"1248\" height=\"331\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM2.png 1248w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM2-300x80.png 300w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM2-768x204.png 768w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM2-1024x272.png 1024w\" sizes=\"auto, (max-width: 1248px) 100vw, 1248px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Alright. Let\u2019s set up Google Analytics. The first thing to do is to create a property in GA and copy the UA-ID. <\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-933\" src=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM3.png\" alt=\"GTM3\" width=\"774\" height=\"367\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM3.png 774w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM3-300x142.png 300w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM3-768x364.png 768w\" sizes=\"auto, (max-width: 774px) 100vw, 774px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">In GTM Tracking codes are implemented as <\/span><b><i>Tags<\/i><\/b><span style=\"font-weight: 400;\">. So when you want to add Facebook\u2019s Tracking \u00a0Pixel you\u2019d simply create a new tag for it and bind it to a <\/span><b><i>Trigger<\/i><\/b><span style=\"font-weight: 400;\"> (pageview, click, form submission,..) to fire on. Lets create our first tag for Analytics, fill the form as seen in the screenshot below. But keep in mind to use your own UA-ID. Leave the \u201cFire On\u201d empty for now. We need to create a trigger first. \u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-932\" src=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM4.png\" alt=\"GTM4\" width=\"924\" height=\"925\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM4.png 924w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM4-150x150.png 150w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM4-300x300.png 300w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM4-768x769.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Alright our tracking snippet is now included but will never be fired since there is no trigger. On Angular 2 Sites we have no real pageview (hard reload) but only state changes that do not trigger the browser reload. This means we have to implement the trigger on our own. This is not Google Tag Manager specific but applies for all fully JavaScript driven pages! Go to GTM and create a new trigger of type <\/span><i><span style=\"font-weight: 400;\">History Changes<\/span><\/i><span style=\"font-weight: 400;\">. Call it \u201cRoute Change\u201d.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/Screenshot-from-2016-10-17-09-41-01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1081\" src=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/Screenshot-from-2016-10-17-09-41-01.png\" alt=\"screenshot-from-2016-10-17-09-41-01\" width=\"1250\" height=\"910\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/Screenshot-from-2016-10-17-09-41-01.png 1250w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/Screenshot-from-2016-10-17-09-41-01-300x218.png 300w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/Screenshot-from-2016-10-17-09-41-01-768x559.png 768w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/Screenshot-from-2016-10-17-09-41-01-1024x745.png 1024w\" sizes=\"auto, (max-width: 1250px) 100vw, 1250px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>GTM will now observe the HTML 5 History API. Any route change will call the trigger. Now it is time to connect the trigger to our Google Analytics Tag. Go to Tags and select the GA tag. <span style=\"font-weight: 400;\">Change the \u201cFire On\u201d -&gt; \u201cMore\u201d -&gt; \u201cRoute Change\u201d. \u00a0Then save the tag and publish your changes by using the publish button in the upper red corner.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-930\" src=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM6.png\" alt=\"GTM6\" width=\"1241\" height=\"915\" srcset=\"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM6.png 1241w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM6-300x221.png 300w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM6-768x566.png 768w, https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2016\/07\/GTM6-1024x755.png 1024w\" sizes=\"auto, (max-width: 1241px) 100vw, 1241px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">This tutorial applies not only to Google Tag Manager and Google Analytics but to all tracking tools that can be connected to GTM. So you can add Piwik, Facebook, AdWords Tracking, Crazyegg, and many more without even touching your application&#8217;s source code once.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<h1>Analytics in Angular 2 (without Google Tag Manager):<\/h1>\n<p>It is indeed not necessary to use Tag Manager. Rather you can implement plain Google Analytics into your single page application. The initial setup may seam easier but you have to repeat this implementation for every new tracking code.\u00a0Copy the full tracking code of your Analytics property and put it in your index.html above your own JavaScript ressources, \u00a0then remove the last line which is responsible for the page view:<\/p>\n<pre class=\"lang:default decode:true \" title=\"index.html\">&lt;body&gt;\r\n&lt;script&gt;\r\n  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\r\n  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\r\n  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\r\n  })(window,document,'script','https:\/\/www.google-analytics.com\/analytics.js','ga');\r\n\r\n  ga('create', 'UA-XXXXXX-ID', 'auto');\r\n  ga('send', 'pageview'); &lt;!-- &lt;- REMOVE THIS LINE --&gt;\r\n\r\n&lt;\/script&gt;<\/pre>\n<p><strong>MAKE SURE TO INSERT YOUR OWN UA-ID!<\/strong><\/p>\n<p>Now go to your app.ts and subscribe to router changes:<\/p>\n<pre class=\"lang:default decode:true\" title=\"app.ts\">import {Component} from '@angular\/core';\r\nimport {Router, NavigationEnd} from '@angular\/router';\r\ndeclare let ga: Function;\r\n\r\n@Component({\r\n  selector: 'my-app',\r\n  templateUrl: '.\/app.html',\r\n  providers: [],\r\n})\r\n\r\nexport class AppComponent {\r\n  constructor(public router: Router) {\r\n    this.router.events.subscribe(event =&gt; {\r\n      if (event instanceof NavigationEnd) {\r\n        ga('set', 'page', event.urlAfterRedirects);\r\n        ga('send', 'pageview');\r\n      }\r\n    });\r\n  }\r\n}\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many modules to include Google Analytics into your Angular 2 project. But actually this overhead is not really required since a plain implementation is only a few lines of code. So you can spare extra modules. I highly recommend you to use Google Tag Manager in order to place the tracking information on [&#8230;]<br \/><a class=\"meta-big\" href=\"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/\"> READ MORE<\/a><\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,2,60],"tags":[],"class_list":["post-926","post","type-post","status-publish","format-standard","hentry","category-angular","category-javascript","category-typescript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Angular 2: Set up Google Analytics and Google Tag Manager - Web Development Blog<\/title>\n<meta name=\"description\" content=\"Unleash Angular 2 analytics. Integrate Google Analytics and Tag Manager effortlessly. Elevate tracking precision. Transform your app insights now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular 2: Set up Google Analytics and Google Tag Manager - Web Development Blog\" \/>\n<meta property=\"og:description\" content=\"Unleash Angular 2 analytics. Integrate Google Analytics and Tag Manager effortlessly. Elevate tracking precision. Transform your app insights now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development tips and tricks - theCodeCampus Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-14T08:04:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-20T19:21:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png\" \/>\n<meta name=\"author\" content=\"theCodeCampus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"theCodeCampus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/\"},\"author\":{\"name\":\"theCodeCampus\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/276bbda2f8da73154f22fb652201cfbc\"},\"headline\":\"Angular 2: Set up Google Analytics and Google Tag Manager\",\"datePublished\":\"2016-07-14T08:04:15+00:00\",\"dateModified\":\"2023-12-20T19:21:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/\"},\"wordCount\":691,\"commentCount\":28,\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.thecodecampus.de\\\/wp-content\\\/uploads\\\/2016\\\/07\\\/GTM1.png\",\"articleSection\":[\"Angular\",\"JavaScript\",\"TypeScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/\",\"name\":\"Angular 2: Set up Google Analytics and Google Tag Manager - Web Development Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.thecodecampus.de\\\/wp-content\\\/uploads\\\/2016\\\/07\\\/GTM1.png\",\"datePublished\":\"2016-07-14T08:04:15+00:00\",\"dateModified\":\"2023-12-20T19:21:56+00:00\",\"description\":\"Unleash Angular 2 analytics. Integrate Google Analytics and Tag Manager effortlessly. Elevate tracking precision. Transform your app insights now!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.thecodecampus.de\\\/wp-content\\\/uploads\\\/2016\\\/07\\\/GTM1.png\",\"contentUrl\":\"https:\\\/\\\/blog.thecodecampus.de\\\/wp-content\\\/uploads\\\/2016\\\/07\\\/GTM1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/angular-2-google-analytics-google-tag-manager\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Angular 2: Set up Google Analytics and Google Tag Manager\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"name\":\"Web Development tips and tricks - theCodeCampus Blog\",\"description\":\"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#organization\",\"name\":\"theCodeCampus\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch.jpg\",\"width\":156,\"height\":156,\"caption\":\"theCodeCampus\"},\"image\":{\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/#\\\/schema\\\/person\\\/276bbda2f8da73154f22fb652201cfbc\",\"name\":\"theCodeCampus\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg\",\"caption\":\"theCodeCampus\"},\"description\":\"Our knowledge is not simply gained through reading - it is trained, tested and constantly being expanded. Because first and foremost, we are all developers at W11K. The know-how that we acquire here as developers, consultants and information architects flows immediately into our training courses and articles for theCodeCampus.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/showcase\\\/thecodecampus\\\/\"],\"url\":\"https:\\\/\\\/www.thecodecampus.de\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Angular 2: Set up Google Analytics and Google Tag Manager - Web Development Blog","description":"Unleash Angular 2 analytics. Integrate Google Analytics and Tag Manager effortlessly. Elevate tracking precision. Transform your app insights now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/","og_locale":"en_US","og_type":"article","og_title":"Angular 2: Set up Google Analytics and Google Tag Manager - Web Development Blog","og_description":"Unleash Angular 2 analytics. Integrate Google Analytics and Tag Manager effortlessly. Elevate tracking precision. Transform your app insights now!","og_url":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/","og_site_name":"Web Development tips and tricks - theCodeCampus Blog","article_published_time":"2016-07-14T08:04:15+00:00","article_modified_time":"2023-12-20T19:21:56+00:00","og_image":[{"url":"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png","type":"","width":"","height":""}],"author":"theCodeCampus","twitter_card":"summary_large_image","twitter_misc":{"Written by":"theCodeCampus","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#article","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/"},"author":{"name":"theCodeCampus","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/276bbda2f8da73154f22fb652201cfbc"},"headline":"Angular 2: Set up Google Analytics and Google Tag Manager","datePublished":"2016-07-14T08:04:15+00:00","dateModified":"2023-12-20T19:21:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/"},"wordCount":691,"commentCount":28,"publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png","articleSection":["Angular","JavaScript","TypeScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/","url":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/","name":"Angular 2: Set up Google Analytics and Google Tag Manager - Web Development Blog","isPartOf":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#primaryimage"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png","datePublished":"2016-07-14T08:04:15+00:00","dateModified":"2023-12-20T19:21:56+00:00","description":"Unleash Angular 2 analytics. Integrate Google Analytics and Tag Manager effortlessly. Elevate tracking precision. Transform your app insights now!","breadcrumb":{"@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#primaryimage","url":"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png","contentUrl":"https:\/\/blog.thecodecampus.de\/wp-content\/uploads\/2016\/07\/GTM1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.thecodecampus.de\/blog\/angular-2-google-analytics-google-tag-manager\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.thecodecampus.de\/blog\/"},{"@type":"ListItem","position":2,"name":"Angular 2: Set up Google Analytics and Google Tag Manager"}]},{"@type":"WebSite","@id":"https:\/\/www.thecodecampus.de\/blog\/#website","url":"https:\/\/www.thecodecampus.de\/blog\/","name":"Web Development tips and tricks - theCodeCampus Blog","description":"Tips, tricks, and experiences about developing web and mobile applications with Angular, TypeScript, and Testing.","publisher":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.thecodecampus.de\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.thecodecampus.de\/blog\/#organization","name":"theCodeCampus","url":"https:\/\/www.thecodecampus.de\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch.jpg","width":156,"height":156,"caption":"theCodeCampus"},"image":{"@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.thecodecampus.de\/blog\/#\/schema\/person\/276bbda2f8da73154f22fb652201cfbc","name":"theCodeCampus","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","url":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","contentUrl":"https:\/\/www.thecodecampus.de\/blog\/wp-content\/uploads\/2024\/01\/TCC-Logo-Bildmarke-quadratisch-96x96.jpg","caption":"theCodeCampus"},"description":"Our knowledge is not simply gained through reading - it is trained, tested and constantly being expanded. Because first and foremost, we are all developers at W11K. The know-how that we acquire here as developers, consultants and information architects flows immediately into our training courses and articles for theCodeCampus.","sameAs":["https:\/\/www.linkedin.com\/showcase\/thecodecampus\/"],"url":"https:\/\/www.thecodecampus.de\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/comments?post=926"}],"version-history":[{"count":29,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/926\/revisions"}],"predecessor-version":[{"id":2173,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/posts\/926\/revisions\/2173"}],"wp:attachment":[{"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/media?parent=926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/categories?post=926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thecodecampus.de\/blog\/wp-json\/wp\/v2\/tags?post=926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}