{"id":100309,"date":"2025-02-20T22:54:03","date_gmt":"2025-02-20T22:54:03","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/gtmtips-create-utility-variables-by-returning-functions\/"},"modified":"2025-02-20T22:54:03","modified_gmt":"2025-02-20T22:54:03","slug":"gtmtips-create-utility-variables-by-returning-functions","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=100309","title":{"rendered":"#GTMTips: Create Utility Variables By Returning Functions"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p>In <a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager<\/a>, the <a href=\"https:\/\/www.simoahava.com\/analytics\/variable-guide-google-tag-manager\/#4-custom-javascript\">Custom JavaScript variable<\/a> is an <strong>anonymous function<\/strong> with a <code>return<\/code> statement. It does not take any parameters, and by default it\u2019s <strong>impossible<\/strong> to pass any parameters to it, because the Custom JS variable is simply resolved to whatever value the function returns. If it returns a number, for example, passing a parameter to it would make no sense and would result in a <code>TypeError<\/code> since the variable resolves to a number, not a function.<\/p>\n<p>However, you can actually have the variable <strong>return a function<\/strong>. You can use this to create your own <strong>utilities<\/strong>, which take parameters and, in turn, return some new value based on the calculations done with the variables.<\/p>\n<p>This isn\u2019t a novel discovery &#8211; variables returning functions are at the core of how things like <a href=\"https:\/\/www.simoahava.com\/gtm-tips\/hitcallback-eventcallback\/\"><code>hitCallback<\/code><\/a> and <a href=\"https:\/\/www.simoahava.com\/analytics\/customtask-the-guide\/\"><code>customTask<\/code><\/a> work. In this article, I\u2019ll explain a bit further what you can do with these utility variables.<\/p>\n<p>                <span class=\"simmer\"><br \/>\n  <span class=\"close\">X<\/span><\/p>\n<p>\n    <span class=\"fa fa-md fa-bell\"\/><br \/>\n    <strong>The Simmer Newsletter<\/strong>\n  <\/p>\n<p>\n    Subscribe to the <a href=\"https:\/\/www.simoahava.com\/newsletter\/\">Simmer newsletter<\/a> to get the latest news and content from Simo Ahava into your email inbox!\n  <\/p>\n<p>  <\/span><\/p>\n<h2 id=\"tip-97-create-utilities-with-the-custom-javascript-variable\">Tip 97: Create utilities with the Custom JavaScript variable<\/h2>\n<div style=\"aspect-ratio: 960 \/ 540;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2019\/03\/javascript-return-function-utility.jpg\" title=\"Return functions with Custom JavaScript variables\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"540\" width=\"960\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2019\/03\/javascript-return-function-utility.jpg#ZgotmplZ\" alt=\"Return functions with Custom JavaScript variables\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>A <strong>function<\/strong> which <strong>returns a function<\/strong> has plenty of use in JavaScript. It\u2019s sometimes called a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Closures\"><strong>closure<\/strong><\/a> because it has access to the lexical scope of the wrapping function even after that function has ended execution.<\/p>\n<p>In Google Tag Manager, using the function as a closure isn\u2019t necessarily the biggest perk, because Custom JavaScript variables are designed to be ephemeral &#8211; simply processing things in scope (e.g. other variables), and then returning the result of this processing.<\/p>\n<p>However, when you <strong>return a function<\/strong> which accepts parameters in a Custom JavaScript variable, you can create a utility that can be invoked from Custom HTML tags and other Custom JavaScript variables without having to always rewrite the same code in all the places you need to the utility.<\/p>\n<p>For example, let\u2019s say you want to create a <strong>browser cookie<\/strong> in a Custom HTML tag. You have some options:<\/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-html\" data-lang=\"html\">script&gt;\n  <span style=\"color:#aaa;font-style:italic\">\/\/ Option 1: Create a global method\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#0aa\">window<\/span>._setCookie = <span style=\"color:#00a\">function<\/span>(name, value, ms, path, domain) {\n    <span style=\"color:#00a\">if<\/span> (!name || !value) {\n      <span style=\"color:#00a\">return<\/span>;\n    }\n    <span style=\"color:#00a\">var<\/span> d;\n    <span style=\"color:#00a\">var<\/span> cpath = path ? <span style=\"color:#a50\">'; path='<\/span> + path : <span style=\"color:#a50\">''<\/span>;\n    <span style=\"color:#00a\">var<\/span> cdomain = domain ? <span style=\"color:#a50\">'; domain='<\/span> + domain : <span style=\"color:#a50\">''<\/span>;\n    <span style=\"color:#00a\">var<\/span> expires = <span style=\"color:#a50\">''<\/span>;\n    <span style=\"color:#00a\">if<\/span> (ms) {\n      d = <span style=\"color:#00a\">new<\/span> <span style=\"color:#0aa\">Date<\/span>();\n      d.setTime(d.getTime() + ms);\n      expires = <span style=\"color:#a50\">'; expires='<\/span> + d.toUTCString();\n    }\n    <span style=\"color:#0aa\">document<\/span>.cookie = name + <span style=\"color:#a50\">\"=\"<\/span> + value + expires + cpath + cdomain;\n  };\n  \n  <span style=\"color:#0aa\">window<\/span>._setCookie(<span style=\"color:#a50\">'someCookieName'<\/span>, <span style=\"color:#a50\">'someCookieValue'<\/span>);\n  \n  <span style=\"color:#aaa;font-style:italic\">\/\/ Option 2: Directly call the document.cookie API\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#0aa\">document<\/span>.cookie = <span style=\"color:#a50\">'someCookieName=someCookieValue'<\/span>;\n  \n  <span style=\"color:#aaa;font-style:italic\">\/\/ Option 3: Use a Custom JavaScript variable\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  {{Set Cookie}}(<span style=\"color:#a50\">'someCookieName=someCookieValue'<\/span>);\n<span style=\"color:#1e90ff;font-weight:bold\">script<\/span>&gt;<\/code><\/pre>\n<\/div>\n<p><strong>Option 1<\/strong> creates a utility method, too, but it adds it to the global namespace. Yes, this has the added benefit of being available to all your Custom HTML tags and Custom JavaScript variables, and actually <strong>any other script<\/strong> running on your site, even outside GTM. Assuming these other tags and scripts run <strong>after<\/strong> the <code>_setCookie<\/code> global method has been created with this tag, that is.<\/p>\n<p>The downside is that you\u2019re <strong>polluting the global namespace<\/strong>. You\u2019re reserving a key that might be overwritten or accessed by any other JavaScript running on the site. If only scripts within GTM need this method, you\u2019d be better off with some other solution.<\/p>\n<p><strong>Option 2<\/strong> is simple in that you don\u2019t need a function at all, you\u2019re directly writing the cookie. With the example above it\u2019s really the simplest way to go about it. However, as soon as you need to do some extra processing, such as determining on which domain or path to write the cookie or what its expiration should be, you\u2019ll add lines and lines of code, and all of these lines need to be rewritten in any other tag where you also want to write a cookie.<\/p>\n<p><strong>Option 3<\/strong> is what this article is about. Instead of adding the <code>_setCookie<\/code> method into the global scope of the page, you can use Google Tag Manager\u2019s Custom JavaScript variables to handle the logic for you. The variable would look like this:<\/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\"><span style=\"color:#00a\">function<\/span>() {\n  <span style=\"color:#00a\">return<\/span> <span style=\"color:#00a\">function<\/span>(name, value, ms, path, domain) {\n    <span style=\"color:#00a\">if<\/span> (!name || !value) {\n      <span style=\"color:#00a\">return<\/span>;\n    }\n    <span style=\"color:#00a\">var<\/span> d;\n    <span style=\"color:#00a\">var<\/span> cpath = path ? <span style=\"color:#a50\">'; path='<\/span> + path : <span style=\"color:#a50\">''<\/span>;\n    <span style=\"color:#00a\">var<\/span> cdomain = domain ? <span style=\"color:#a50\">'; domain='<\/span> + domain : <span style=\"color:#a50\">''<\/span>;\n    <span style=\"color:#00a\">var<\/span> expires = <span style=\"color:#a50\">''<\/span>;\n    <span style=\"color:#00a\">if<\/span> (ms) {\n      d = <span style=\"color:#00a\">new<\/span> <span style=\"color:#0aa\">Date<\/span>();\n      d.setTime(d.getTime() + ms);\n      expires = <span style=\"color:#a50\">'; expires='<\/span> + d.toUTCString();\n    }\n    <span style=\"color:#0aa\">document<\/span>.cookie = name + <span style=\"color:#a50\">\"=\"<\/span> + value + expires + cpath + cdomain;\n  }\n}\n<\/code><\/pre>\n<\/div>\n<p>As you can see, it\u2019s almost the same as <strong>Option 1<\/strong>, except instead of assigning the function to a global variable, you\u2019re <strong>returning<\/strong> it in the Custom JavaScript variable. And because you return the function, you can then invoke it with the parameters <code>name, value, ms, path, domain<\/code>, and have the function handle writing the cookie for you.<\/p>\n<p>Assuming you\u2019ll name that Custom JavaScript variable as <strong>Set cookie variable<\/strong>, this is how you would invoke it from a Custom HTML tag or a Custom JavaScript variable:<\/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\">{{Set cookie variable}}(<span style=\"color:#a50\">'cookieName'<\/span>, <span style=\"color:#a50\">'cookieValue'<\/span>, <span style=\"color:#099\">100000<\/span>, <span style=\"color:#a50\">'\/'<\/span>, <span style=\"color:#a50\">'simoahava.com'<\/span>);\n<\/code><\/pre>\n<\/div>\n<p>This is just one example. You could also\u2026<\/p>\n<ul>\n<li>\n<p>Create a <a href=\"https:\/\/geraintluff.github.io\/sha256\/\">SHA-256 hashing function<\/a> (thanks <strong>Johan Terpstra<\/strong> for the link to the source code), which encrypts any string passed to it.<\/p>\n<\/li>\n<li>\n<p>Create <a href=\"https:\/\/codepen.io\/andrewarchi\/pen\/Klhqm\">simple utilities<\/a> such as string reversal, array equality checks, and converters.<\/p>\n<\/li>\n<li>\n<p>Write <a href=\"https:\/\/www.simoahava.com\/analytics\/simple-custom-event-listeners-gtm\/#the-custom-javascript-variable\">callbacks<\/a> for custom event listeners.<\/p>\n<\/li>\n<\/ul>\n<p>In summary, a Custom JavaScript variable which returns a function is useful if you want to\u2026<\/p>\n<ol>\n<li>\n<p>Avoid <strong>polluting the global namespace<\/strong>.<\/p>\n<\/li>\n<li>\n<p>Avoid <strong>rewriting the same code over and over again<\/strong>. and\/or c) <strong>having a number of similar variables doing almost the same thing<\/strong>.<\/p>\n<\/li>\n<li>\n<p>Avoid <strong>having a number of similar variables doing almost the same thing<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p>The last point is especially powerful, as instead of having five different Custom JavaScript variables, you could use a single Custom JavaScript variable, returning a function which takes a parameter, and this function would then return one of five different outcomes, depending on the parameter.<\/p>\n<p>Just remember that you can only run JavaScript in two contexts within GTM: Custom HTML tags and Custom JavaScript variables. So you can\u2019t add parameters to a Custom JavaScript variable in regular tag, trigger, or variable fields.<\/p>\n<p>Do you have any cool utility functions you\u2019d like to share with the readers?<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>In Google Tag Manager, the Custom JavaScript variable is an anonymous function with a return statement. It does not take any parameters, and by default it\u2019s impossible to pass any parameters to it, because the Custom JS variable is simply resolved to whatever value the function returns. If it returns a number, for example, passing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":100310,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[7957,18213,14492,23055,5808,30217],"dealstore":[],"offerexpiration":[],"class_list":["post-100309","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-create","tag-functions","tag-gtmtips","tag-returning","tag-utility","tag-variables"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>#GTMTips: Create Utility Variables By Returning Functions - 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=100309\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"#GTMTips: Create Utility Variables By Returning Functions - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"In Google Tag Manager, the Custom JavaScript variable is an anonymous function with a return statement. It does not take any parameters, and by default it\u2019s impossible to pass any parameters to it, because the Custom JS variable is simply resolved to whatever value the function returns. If it returns a number, for example, passing [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=100309\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-20T22:54:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=100309#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=100309\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"#GTMTips: Create Utility Variables By Returning Functions\",\"datePublished\":\"2025-02-20T22:54:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=100309\"},\"wordCount\":869,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=100309#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg\",\"keywords\":[\"create\",\"Functions\",\"GTMTips\",\"Returning\",\"Utility\",\"Variables\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=100309#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=100309\",\"url\":\"https:\/\/fivemor.com\/?p=100309\",\"name\":\"#GTMTips: Create Utility Variables By Returning Functions - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=100309#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=100309#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg\",\"datePublished\":\"2025-02-20T22:54:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=100309#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=100309\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=100309#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg\",\"width\":960,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=100309#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"#GTMTips: Create Utility Variables By Returning Functions\"}]},{\"@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":"#GTMTips: Create Utility Variables By Returning Functions - 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=100309","og_locale":"en_US","og_type":"article","og_title":"#GTMTips: Create Utility Variables By Returning Functions - Som2ny Network","og_description":"In Google Tag Manager, the Custom JavaScript variable is an anonymous function with a return statement. It does not take any parameters, and by default it\u2019s impossible to pass any parameters to it, because the Custom JS variable is simply resolved to whatever value the function returns. If it returns a number, for example, passing [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=100309","og_site_name":"Som2ny Network","article_published_time":"2025-02-20T22:54:03+00:00","og_image":[{"width":960,"height":540,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=100309#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=100309"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"#GTMTips: Create Utility Variables By Returning Functions","datePublished":"2025-02-20T22:54:03+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=100309"},"wordCount":869,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=100309#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg","keywords":["create","Functions","GTMTips","Returning","Utility","Variables"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=100309#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=100309","url":"https:\/\/fivemor.com\/?p=100309","name":"#GTMTips: Create Utility Variables By Returning Functions - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=100309#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=100309#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg","datePublished":"2025-02-20T22:54:03+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=100309#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=100309"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=100309#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/javascript-return-function-utility.jpg","width":960,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=100309#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"#GTMTips: Create Utility Variables By Returning Functions"}]},{"@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\/100309","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=100309"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/100309\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/100310"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100309"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=100309"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=100309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}