{"id":8043,"date":"2022-10-20T12:45:05","date_gmt":"2022-10-20T12:45:05","guid":{"rendered":"https:\/\/docs.campaignsuite.nl\/docs\/gravity-forms\/measurement\/google-tag-manager\/"},"modified":"2022-10-20T12:48:23","modified_gmt":"2022-10-20T12:48:23","slug":"google-tag-manager","status":"publish","type":"docs","link":"https:\/\/docs.campaignsuite.nl\/en\/docs\/gravity-forms\/measurement\/google-tag-manager\/","title":{"rendered":"Google Tag Manager"},"content":{"rendered":"\n<p><img decoding=\"async\" style=\"width: 150px;\" src=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/gtm_logo.png\" align=\"right\">Google Tag Manager (GTM) is a tool from Google that allows you as an online marketer, entrepreneur or social media specialist to become less dependent on your developers or an external agency. By means of Google Tag Manager you ensure that you can make useful tags such as Google Analytics or the Meta Pixel work without having to ask your web builder to place the tags in the code of your website.<\/p>\n\n\n\n<p>In Measurements you have the option to make Client Side and Server Side calls for GTM. Client Side calls are not available for the events <strong>After a webhook call from Findock<\/strong> <strong>v2<\/strong> and <strong>After a successful payment<\/strong>. The Client Side calls use the datalayer.push() function. The data can then be read by the GTM pixel on your website:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- Google Tag Manager --&gt;\n&lt;script&gt;(function(w,d,s,l,i){w&#91;l]=w&#91;l]||&#91;];w&#91;l].push({' gtm.start':\nnew Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)&#91;0],\nj=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src=\n'https:\/\/www.googletagmanager.com\/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n})(window,document,'script','dataLayer','UNIQUE_ID');&lt;\/script&gt;\n&lt;!-- End Google Tag Manager --&gt;<\/code><\/pre>\n\n\n\n<p>In the above code, replace UNIQUE_ID with your own Google Tag Manager ID.<\/p>\n\n\n\n<p>Server Side calls are only available if a value is entered in the CampaignSuite settings for the field <strong>GTM SST URL<\/strong> (Google Tag Manager Server Side Tracking URL). This URL (also called Tag Manager server container) can be created in Google Tag Manager. Read <a rel=\"noreferrer noopener\" href=\"https:\/\/developers.google.com\/tag-platform\/tag-manager\/server-side\" data-type=\"URL\" data-id=\"https:\/\/ developers.google.com\/tag-platform\/tag-manager\/server-side\" target=\"_blank\">here<\/a> to learn more about how to create a Tag Manager server container. When you fill in the <strong>Measurement ID<\/strong> field with the ID from GTM, it will automatically be included in the Server Side calls in the parameter <strong><em>tid<\/em><\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Client Side<\/h3>\n\n\n\n<p>When a Client Side call is made via the Google Tag Manager provider, CampaignSuite automatically detects whether it is an E-commerce Measurement call or not. We do this based on the mapping of the <strong>Price<\/strong> parameter of the product. If this parameter is mapped, the datalayer.push() will have an e-commerce syntax. In all other cases it will be a simple version of a datalayer.push(). Below are 2 examples of a simple and an e-commerce Client Side call.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example of the mapping (simple):<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"912\" height=\"366\" src=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_simple.png\" alt=\"\" class=\"wp-image-8032\" srcset=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_simple.png 912w, https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_simple-300x120.png 300w, https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_simple-768x308.png 768w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Example of the datalayer.push() Javascript code:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script type='text\/javascript'&gt;\n  dataLayer.push({\n    event: \"page_switch\",\n    page: \"1\"\n  });\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Example of the mapping (e-commerce):<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"905\" height=\"806\" src=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_ecommerce-1.png\" alt=\"\" class=\"wp-image-8026\" srcset=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_ecommerce-1.png 905w, https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_ecommerce-1-300x267.png 300w, https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_client_ecommerce-1-768x684.png 768w\" sizes=\"auto, (max-width: 905px) 100vw, 905px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Example of the datalayer.push() Javascript code:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script type='text\/javascript'&gt;\n  dataLayer.push({ ecommerce: null });\n  dataLayer.push({\n    event: \"purchase\",\n    transaction_id: \"349\",\n    e-commerce: {\n      value: 12.45,\n      payment_type: \"Ideal\",\n      items: &#91;\n        {\n          item_id: \"1\",\n          item_name: \"Donation\",\n          price: 12.45,\n          quantity: 1\n        }\n      ]\n    }\n  });\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Server Side<\/h3>\n\n\n\n<p>It is only possible to make Server Side calls if there is a Tag Managa server container has been created and set up. This container can be accessed via a separate URL (for example: https:\/\/sst.testwebsite.nl\/g\/collect) which must be set in the CampaignSuite settings under <strong>GTM SST URL<\/strong>.<\/p>\n\n\n\n<p>The parameters mapped in the block of Google Tag Manager at Measurements will be sent in the URL that CampaignSuite calls via a GET request. Check out <a href=\"https:\/\/www.thyngster.com\/ga4-measurement-protocol-cheatsheet\/\" target=\"_blank\" rel=\"noreferrer noopener\">this page<\/a> to see which parameters are supported .<\/p>\n\n\n\n<p>The example below shows a Server Side call upon successful payment:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example of the mapping:<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_server.png\" alt=\" \" class=\"wp-image-8039\" width=\"744\" height=\"870\" srcset=\"https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_server.png 701w, https:\/\/docs.campaignsuite.nl\/wp-content\/uploads\/2022\/10\/measurement_gtm_server-256x300.png 256w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">GET request URL being executed:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>https:\/\/sst.testwebsite.nl\/g\/collect?v=2&amp;cid=278327074.1665398324&amp;tid=G-AB1CDEFG23&amp; en=payment&amp;cu=EUR&amp;ep.fbc=undefined&amp;ep.transaction_id=346&amp;epn.value=100&amp;ep.typedonatie=One-time&amp;ep.email=test@test.nl&amp;pr1=idonce_0~nmdonatie_via_website~ pr100~qt1~caIdeal<\/code><\/pre>\n\n\n\n<p>All product fields are merged and all individual parameters are pasted after the URL. In this way a Server Side call is made for Google Tag Manager.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Tag Manager (GTM) is a tool from Google that allows you as an online marketer, entrepreneur or social media specialist to become less dependent on your developers or an external agency. By means of Google Tag Manager you ensure that you can make useful tags such as Google Analytics or the Meta Pixel work [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":7768,"menu_order":7,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-8043","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/8043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/comments?post=8043"}],"version-history":[{"count":2,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/8043\/revisions"}],"predecessor-version":[{"id":8047,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/8043\/revisions\/8047"}],"up":[{"embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/docs\/7768"}],"wp:attachment":[{"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/media?parent=8043"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/docs.campaignsuite.nl\/en\/wp-json\/wp\/v2\/doc_tag?post=8043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}