{"id":67928,"date":"2025-02-04T14:00:18","date_gmt":"2025-02-04T14:00:18","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/core-web-vitals-custom-tag-template\/"},"modified":"2025-02-04T14:00:18","modified_gmt":"2025-02-04T14:00:18","slug":"core-web-vitals-custom-tag-template","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=67928","title":{"rendered":"Core Web Vitals &#8211; Custom Tag Template"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<div style=\"aspect-ratio: 1358 \/ 738;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2021\/05\/core-web-vitals.jpg\" title=\"Core Web Vitals\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"738\" width=\"1358\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2021\/05\/core-web-vitals.jpg#ZgotmplZ\" alt=\"Core Web Vitals\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Core Web Vitals<\/strong> <a href=\"https:\/\/www.simoahava.com\/analytics\/custom-templates-guide-for-google-tag-manager\/\">custom tag template<\/a> is a tag template for <a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager\u2019s<\/a> <a href=\"https:\/\/tagmanager.google.com\/gallery\/\">community template gallery<\/a>.<\/p>\n<h3 id=\"description\">Description<\/h3>\n<p>This tag adds measurement handlers for three <a href=\"https:\/\/web.dev\/vitals\/\">Core Web Vitals<\/a>: Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS).<\/p>\n<p>There is also a toggle (<strong>Collect all (available) web vitals metrics<\/strong>) that enables the collection of other supported Web Vitals metrics: FCP, INP, and TTFB.<\/p>\n<p>Each measurement is pushed into <code>dataLayer<\/code> as soon as it is available.<\/p>\n<blockquote>\n<p>Note that not every page load will register all three milestones. Read the documentation linked to above to understand why.<\/p>\n<\/blockquote>\n<h3 id=\"instructions\">Instructions<\/h3>\n<p>The template itself has just one configurable option: <strong>Namespace Objects<\/strong>. If this is checked, then all measurements will be nested under an object property of the measurement name (see below for an example).<\/p>\n<p>Set the tag to fire on the <strong>All Pages<\/strong> trigger. If you only want to measure some pages, use a <strong>Page View<\/strong> trigger with a suitable trigger condition instead.<\/p>\n<p>The tag writes the following objects into <code>dataLayer<\/code> for each time they are measured (CLS, for example, can be measured more than once per page).<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  event: <span style=\"color:#a50\">'coreWebVitals'<\/span>,\n  webVitalsMeasurement: {\n    name: <span style=\"color:#a50\">'LCP'<\/span>,\n    id: <span style=\"color:#a50\">'v1-123123123-123123123'<\/span>,\n    value: <span style=\"color:#099\">123.55<\/span>,\n    delta: <span style=\"color:#099\">13.68<\/span>,\n    valueRounded: <span style=\"color:#099\">124<\/span>,\n    deltaRounded: <span style=\"color:#099\">14<\/span>\n  }\n}\n<\/code><\/pre>\n<\/div>\n<p>If you have <strong>Namespace Objects<\/strong> checked, then the measurement above would be pushed to <code>dataLayer<\/code> like this instead:<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-javascript\" data-lang=\"javascript\">{\n  event: <span style=\"color:#a50\">'coreWebVitals'<\/span>,\n  webVitalsMeasurement: {\n    LCP: {\n      name: <span style=\"color:#a50\">'LCP'<\/span>,\n      id: <span style=\"color:#a50\">'v1-123123123-123123123'<\/span>,\n      value: <span style=\"color:#099\">123.55<\/span>,\n      delta: <span style=\"color:#099\">13.68<\/span>,\n      valueRounded: <span style=\"color:#099\">124<\/span>,\n      deltaRounded: <span style=\"color:#099\">14<\/span>\n    }\n  }\n}\n<\/code><\/pre>\n<\/div>\n<blockquote>\n<p>Namespacing the measurements like this is useful if you want to send all the current CWV measurements in a single request. If you don\u2019t namespace the objects, then each subsequent measurement will overwrite the keys and values of the previous measurement.<\/p>\n<\/blockquote>\n<p>You can create a <strong>Custom Event trigger<\/strong> for <code>coreWebVitals<\/code> to fire your tag when this <code>dataLayer.push()<\/code> happens.<\/p>\n<p>You need to create <strong>Data Layer variables<\/strong> for all the <code>webVitalsMeasurement.*<\/code> variable names that you want to utilize in your tags.<\/p>\n<p>It\u2019s recommended to use the <a href=\"https:\/\/developers.google.com\/analytics\/devguides\/collection\/analyticsjs\/sending-hits#specifying_different_transport_mechanisms\">Beacon API<\/a> when sending the Core Web Vitals data to the endpoint, as some of the measurements might happen upon page unload.<\/p>\n<blockquote>\n<p>Google Analytics 4 uses the Beacon API automatically, so you don\u2019t need to do anything manually.<\/p>\n<\/blockquote>\n<h3 id=\"release-notes\">Release notes<\/h3>\n<table>\n<thead>\n<tr>\n<th>Date<\/th>\n<th>Changeset<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>21 January 2021<\/td>\n<td>Add rounded integers to the object for\teasier implementation.<\/td>\n<\/tr>\n<tr>\n<td>21 January 2021<\/td>\n<td>Initial release.<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>The Core Web Vitals custom tag template is a tag template for Google Tag Manager\u2019s community template gallery. Description This tag adds measurement handlers for three Core Web Vitals: Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). There is also a toggle (Collect all (available) web vitals metrics) that enables [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":67929,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[3147,834,1791,4196,26018,5393],"dealstore":[],"offerexpiration":[],"class_list":["post-67928","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-core","tag-custom","tag-tag","tag-template","tag-vitals","tag-web"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Core Web Vitals - Custom Tag Template - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=67928\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Core Web Vitals - Custom Tag Template - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"The Core Web Vitals custom tag template is a tag template for Google Tag Manager\u2019s community template gallery. Description This tag adds measurement handlers for three Core Web Vitals: Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). There is also a toggle (Collect all (available) web vitals metrics) that enables [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=67928\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-04T14:00:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1358\" \/>\n\t<meta property=\"og:image:height\" content=\"738\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=67928#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=67928\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Core Web Vitals &#8211; Custom Tag Template\",\"datePublished\":\"2025-02-04T14:00:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=67928\"},\"wordCount\":350,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=67928#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg\",\"keywords\":[\"Core\",\"Custom\",\"TAG\",\"Template\",\"Vitals\",\"Web\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=67928#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=67928\",\"url\":\"https:\/\/fivemor.com\/?p=67928\",\"name\":\"Core Web Vitals - Custom Tag Template - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=67928#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=67928#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg\",\"datePublished\":\"2025-02-04T14:00:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=67928#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=67928\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=67928#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg\",\"width\":1358,\"height\":738},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=67928#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Core Web Vitals &#8211; Custom Tag Template\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Core Web Vitals - Custom Tag Template - Som2ny Network","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:\/\/fivemor.com\/?p=67928","og_locale":"en_US","og_type":"article","og_title":"Core Web Vitals - Custom Tag Template - Som2ny Network","og_description":"The Core Web Vitals custom tag template is a tag template for Google Tag Manager\u2019s community template gallery. Description This tag adds measurement handlers for three Core Web Vitals: Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). There is also a toggle (Collect all (available) web vitals metrics) that enables [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=67928","og_site_name":"Som2ny Network","article_published_time":"2025-02-04T14:00:18+00:00","og_image":[{"width":1358,"height":738,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=67928#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=67928"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Core Web Vitals &#8211; Custom Tag Template","datePublished":"2025-02-04T14:00:18+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=67928"},"wordCount":350,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=67928#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg","keywords":["Core","Custom","TAG","Template","Vitals","Web"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=67928#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=67928","url":"https:\/\/fivemor.com\/?p=67928","name":"Core Web Vitals - Custom Tag Template - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=67928#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=67928#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg","datePublished":"2025-02-04T14:00:18+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=67928#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=67928"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=67928#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/core-web-vitals.jpg","width":1358,"height":738},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=67928#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Core Web Vitals &#8211; Custom Tag Template"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/67928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=67928"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/67928\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/67929"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=67928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=67928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=67928"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=67928"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=67928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}