{"id":6858,"date":"2023-10-25T07:39:32","date_gmt":"2023-10-25T07:39:32","guid":{"rendered":"https:\/\/www.leadshook.com\/help\/?p=6858"},"modified":"2024-02-14T11:39:34","modified_gmt":"2024-02-14T11:39:34","slug":"capturing-hyphenated-parameters-in-leadshook","status":"publish","type":"post","link":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/","title":{"rendered":"Capturing Hyphenated Parameters in LeadsHook"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction:<\/h2>\n\n\n\n<p>In this article, you will learn how to capture hyphenated parameters and save them as custom fields in LeadsHook using JavaScript. <\/p>\n\n\n\n<p>Here&#8217;s a clear step-by-step process using a sample script:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function setFieldsFromUrl() {\n    \/\/ Get the URL parameters\n    const urlParams = new URLSearchParams(window.location.search);\n    \n    \/\/ Get the values of the 'first-name' and 'last-name' parameters\n    const firstName = urlParams.get('first-name');\n    const lastName = urlParams.get('last-name');\n    \n    \/\/ Check if the values are not null or undefined\n    if (firstName !== null &amp;&amp; firstName !== undefined) {\n        \/\/ Log the captured value\n        console.log(`Captured first-name: ${firstName}`);\n        \n        \/\/ Call DT.setField with the captured value\n        DT.setField('first_name', firstName);\n    } else {\n        console.log(\"First name not found in the URL parameters.\");\n    }\n    \n    if (lastName !== null &amp;&amp; lastName !== undefined) {\n        \/\/ Log the captured value\n        console.log(`Captured last-name: ${lastName}`);\n        \n        \/\/ Call DT.setField with the captured value\n        DT.setField('last_name', lastName);\n    } else {\n        console.log(\"Last name not found in the URL parameters.\");\n    }\n}\n\n\/\/ Assuming that DT.setField is defined, you can call the function\nsetFieldsFromUrl();\n<\/code><\/pre>\n\n\n\n<p>In the above script: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extract URL parameters: Using&nbsp;URLSearchParams, you can parse the URL&#8217;s query string to extract parameters.<\/li>\n\n\n\n<li>Retrieve hyphenated parameters: Use&nbsp;.get&nbsp;to retrieve the values of parameters with hyphens, like &#8216;first-name&#8217; and &#8216;last-name&#8217;.<\/li>\n\n\n\n<li>Save to LeadsHook custom fields: If these values exist, use&nbsp;DT.setField&nbsp;to save them in LeadsHook as custom fields (&#8216;first_name&#8217; and &#8216;last_name&#8217; in this case).<\/li>\n<\/ul>\n\n\n\n<p>You can place the script at the node level of your decision tree. Adjust parameters and custom field names as needed.<\/p>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background\"><strong>Important Note:<\/strong> When testing in Version 2 Decision Trees, you can display the custom field in the next node where you put the script. Just keep in mind that in V2, the nodes are pre-rendered on the server side, so the variable won&#8217;t be available in the first node.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: In this article, you will learn how to capture hyphenated parameters and save them as custom fields in LeadsHook using JavaScript. Here&#8217;s a clear step-by-step process using a sample script: In the above script: You can place the script at the node level of your decision tree. Adjust parameters and custom field names as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,620],"tags":[1000,999,775,1001],"class_list":["post-6858","post","type-post","status-publish","format-standard","hentry","category-general","category-scripts","tag-hyphen","tag-hyphenated","tag-scripting","tag-url-parameters"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Capturing Hyphenated Parameters in LeadsHook - LeadsHook Knowledge Base<\/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:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Capturing Hyphenated Parameters in LeadsHook - LeadsHook Knowledge Base\" \/>\n<meta property=\"og:description\" content=\"Introduction: In this article, you will learn how to capture hyphenated parameters and save them as custom fields in LeadsHook using JavaScript. Here&#8217;s a clear step-by-step process using a sample script: In the above script: You can place the script at the node level of your decision tree. Adjust parameters and custom field names as [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/\" \/>\n<meta property=\"og:site_name\" content=\"LeadsHook Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/leadshook\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-25T07:39:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-14T11:39:34+00:00\" \/>\n<meta name=\"author\" content=\"Nik T\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@leadshook\" \/>\n<meta name=\"twitter:site\" content=\"@leadshook\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nik T\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/\"},\"author\":{\"name\":\"Nik T\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#\\\/schema\\\/person\\\/4bfe37d814563cc729828b7055313f4d\"},\"headline\":\"Capturing Hyphenated Parameters in LeadsHook\",\"datePublished\":\"2023-10-25T07:39:32+00:00\",\"dateModified\":\"2024-02-14T11:39:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/\"},\"wordCount\":174,\"publisher\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#organization\"},\"keywords\":[\"hyphen\",\"hyphenated\",\"scripting\",\"url parameters\"],\"articleSection\":[\"General\",\"Scripts\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/\",\"url\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/\",\"name\":\"Capturing Hyphenated Parameters in LeadsHook - LeadsHook Knowledge Base\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#website\"},\"datePublished\":\"2023-10-25T07:39:32+00:00\",\"dateModified\":\"2024-02-14T11:39:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/capturing-hyphenated-parameters-in-leadshook\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Capturing Hyphenated Parameters in LeadsHook\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#website\",\"url\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/\",\"name\":\"LeadsHook Knowledge Base\",\"description\":\"LeadsHook Training &amp; Technical Help\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#organization\",\"name\":\"LeadsHook\",\"url\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/wp-content\\\/uploads\\\/2018\\\/12\\\/leadshook-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/wp-content\\\/uploads\\\/2018\\\/12\\\/leadshook-logo.png\",\"width\":350,\"height\":83,\"caption\":\"LeadsHook\"},\"image\":{\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/leadshook\\\/\",\"https:\\\/\\\/x.com\\\/leadshook\",\"https:\\\/\\\/www.linkedin.com\\\/showcase\\\/leadshook\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/#\\\/schema\\\/person\\\/4bfe37d814563cc729828b7055313f4d\",\"name\":\"Nik T\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/48d53e68db0b1db1cd5c54a750130fb2ee0c663306ff1bd434373f1a368ef7a0?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/48d53e68db0b1db1cd5c54a750130fb2ee0c663306ff1bd434373f1a368ef7a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/48d53e68db0b1db1cd5c54a750130fb2ee0c663306ff1bd434373f1a368ef7a0?s=96&d=mm&r=g\",\"caption\":\"Nik T\"},\"sameAs\":[\"http:\\\/\\\/www.LeadsHook.com\"],\"url\":\"https:\\\/\\\/www.leadshook.com\\\/help\\\/author\\\/nik\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Capturing Hyphenated Parameters in LeadsHook - LeadsHook Knowledge Base","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.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/","og_locale":"en_US","og_type":"article","og_title":"Capturing Hyphenated Parameters in LeadsHook - LeadsHook Knowledge Base","og_description":"Introduction: In this article, you will learn how to capture hyphenated parameters and save them as custom fields in LeadsHook using JavaScript. Here&#8217;s a clear step-by-step process using a sample script: In the above script: You can place the script at the node level of your decision tree. Adjust parameters and custom field names as [&hellip;]","og_url":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/","og_site_name":"LeadsHook Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/leadshook\/","article_published_time":"2023-10-25T07:39:32+00:00","article_modified_time":"2024-02-14T11:39:34+00:00","author":"Nik T","twitter_card":"summary_large_image","twitter_creator":"@leadshook","twitter_site":"@leadshook","twitter_misc":{"Written by":"Nik T","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/#article","isPartOf":{"@id":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/"},"author":{"name":"Nik T","@id":"https:\/\/www.leadshook.com\/help\/#\/schema\/person\/4bfe37d814563cc729828b7055313f4d"},"headline":"Capturing Hyphenated Parameters in LeadsHook","datePublished":"2023-10-25T07:39:32+00:00","dateModified":"2024-02-14T11:39:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/"},"wordCount":174,"publisher":{"@id":"https:\/\/www.leadshook.com\/help\/#organization"},"keywords":["hyphen","hyphenated","scripting","url parameters"],"articleSection":["General","Scripts"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/","url":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/","name":"Capturing Hyphenated Parameters in LeadsHook - LeadsHook Knowledge Base","isPartOf":{"@id":"https:\/\/www.leadshook.com\/help\/#website"},"datePublished":"2023-10-25T07:39:32+00:00","dateModified":"2024-02-14T11:39:34+00:00","breadcrumb":{"@id":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.leadshook.com\/help\/capturing-hyphenated-parameters-in-leadshook\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.leadshook.com\/help\/"},{"@type":"ListItem","position":2,"name":"Capturing Hyphenated Parameters in LeadsHook"}]},{"@type":"WebSite","@id":"https:\/\/www.leadshook.com\/help\/#website","url":"https:\/\/www.leadshook.com\/help\/","name":"LeadsHook Knowledge Base","description":"LeadsHook Training &amp; Technical Help","publisher":{"@id":"https:\/\/www.leadshook.com\/help\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.leadshook.com\/help\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.leadshook.com\/help\/#organization","name":"LeadsHook","url":"https:\/\/www.leadshook.com\/help\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.leadshook.com\/help\/#\/schema\/logo\/image\/","url":"https:\/\/www.leadshook.com\/help\/wp-content\/uploads\/2018\/12\/leadshook-logo.png","contentUrl":"https:\/\/www.leadshook.com\/help\/wp-content\/uploads\/2018\/12\/leadshook-logo.png","width":350,"height":83,"caption":"LeadsHook"},"image":{"@id":"https:\/\/www.leadshook.com\/help\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/leadshook\/","https:\/\/x.com\/leadshook","https:\/\/www.linkedin.com\/showcase\/leadshook\/"]},{"@type":"Person","@id":"https:\/\/www.leadshook.com\/help\/#\/schema\/person\/4bfe37d814563cc729828b7055313f4d","name":"Nik T","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/48d53e68db0b1db1cd5c54a750130fb2ee0c663306ff1bd434373f1a368ef7a0?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/48d53e68db0b1db1cd5c54a750130fb2ee0c663306ff1bd434373f1a368ef7a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/48d53e68db0b1db1cd5c54a750130fb2ee0c663306ff1bd434373f1a368ef7a0?s=96&d=mm&r=g","caption":"Nik T"},"sameAs":["http:\/\/www.LeadsHook.com"],"url":"https:\/\/www.leadshook.com\/help\/author\/nik\/"}]}},"_links":{"self":[{"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/posts\/6858","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/comments?post=6858"}],"version-history":[{"count":7,"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/posts\/6858\/revisions"}],"predecessor-version":[{"id":6997,"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/posts\/6858\/revisions\/6997"}],"wp:attachment":[{"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/media?parent=6858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/categories?post=6858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.leadshook.com\/help\/wp-json\/wp\/v2\/tags?post=6858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}