<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extracting Param Value From URL Path Using Custom Code in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/993825#M2385</link>
    <description>&lt;P&gt;Hi Karsten,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response. It helped me get part way to my goal, but not fully isolate value needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the following does copy over the value of the parameter, but it is also copying over everything else after it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-06-18_10-20-32.jpg" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/119964iDFB89E84D6D94D78/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2024-06-18_10-20-32.jpg" alt="2024-06-18_10-20-32.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is example of the value it currently creates, but I want to capture what is green and what I need still removed in red. &lt;FONT color="#008000"&gt;Meet%20the%20Business%20Network%20Newsroom&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&amp;amp;utm_campaign=2024_MTN&amp;amp;utm_medium=email&amp;amp;_hsenc=00000JQJR_KdgJ0E4&amp;amp;_hsmi=000008085&amp;amp;utm_content=000008085&amp;amp;utm_source=hs_email&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want only what is after "&amp;amp;npseventname=" and before "&amp;amp;utm_campaign". I'd then want to unencode it to finally paste the result in another custom property.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 14:31:58 GMT</pubDate>
    <dc:creator>JoshuaW</dc:creator>
    <dc:date>2024-06-18T14:31:58Z</dc:date>
    <item>
      <title>Extracting Param Value From URL Path Using Custom Code</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/958946#M2252</link>
      <description>&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Does anyone know workflow custom code that would extract a specific parameter from the "Last Page Seen" contact property URL to then apply that value to another property for the contact? For example: If the "Last Page Seen" value is the following URL and I'm looking for the param value of "npsevent", I would want the action to copy "CaptureThisValue" to another property.&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;examplewebsite.com/event?npsevent=CaptureThisValue&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can predict the parameter of "npsevent" will always be present, but the value could be different for different contacts and is unpredicable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The workflow the action is in would trigger off of update to "Last Page Seen" property with filter for it to include the specific parameter I need to capture the value of.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 21:47:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/958946#M2252</guid>
      <dc:creator>JoshuaW</dc:creator>
      <dc:date>2024-04-11T21:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting Param Value From URL Path Using Custom Code</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/959144#M2255</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/653702"&gt;@JoshuaW&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should be possible with a regex replace:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="karstenkoehler_0-1712896740714.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/115123iBEE832B1DA38E2FD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="karstenkoehler_0-1712896740714.png" alt="karstenkoehler_0-1712896740714.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not a regex expert but this code snippet should correspond to anything before the parameter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class="code-container" role="text" data-test-id="code-content" data-sourcepos="5:1-7:14"&gt;^.*\?npsevent=&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P data-sourcepos="9:1-9:16"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-sourcepos="9:1-9:16"&gt;Explanation:&lt;/P&gt;
&lt;UL data-sourcepos="11:1-14:0"&gt;
&lt;LI data-sourcepos="11:1-11:43"&gt;&lt;CODE&gt;^&lt;/CODE&gt;: Matches the beginning of the string.&lt;/LI&gt;
&lt;LI data-sourcepos="12:1-12:114"&gt;&lt;CODE&gt;.*&lt;/CODE&gt;: Matches any character (including spaces) zero or more times. This captures everything before "?npsevent=".&lt;/LI&gt;
&lt;LI data-sourcepos="13:1-14:0"&gt;&lt;CODE&gt;\?npsevent=&lt;/CODE&gt;: Matches the exact string "?npsevent=".&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-sourcepos="15:1-15:21"&gt;Replacement Text: Leave the replacement text empty (&lt;CODE&gt;""&lt;/CODE&gt;). This effectively removes the matched portion of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should then be able to save the remaining parameter into a new property. I haven't tested this but it feels doable &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 04:42:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/959144#M2255</guid>
      <dc:creator>karstenkoehler</dc:creator>
      <dc:date>2024-04-12T04:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting Param Value From URL Path Using Custom Code</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/993825#M2385</link>
      <description>&lt;P&gt;Hi Karsten,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response. It helped me get part way to my goal, but not fully isolate value needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the following does copy over the value of the parameter, but it is also copying over everything else after it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-06-18_10-20-32.jpg" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/119964iDFB89E84D6D94D78/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2024-06-18_10-20-32.jpg" alt="2024-06-18_10-20-32.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is example of the value it currently creates, but I want to capture what is green and what I need still removed in red. &lt;FONT color="#008000"&gt;Meet%20the%20Business%20Network%20Newsroom&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;&amp;amp;utm_campaign=2024_MTN&amp;amp;utm_medium=email&amp;amp;_hsenc=00000JQJR_KdgJ0E4&amp;amp;_hsmi=000008085&amp;amp;utm_content=000008085&amp;amp;utm_source=hs_email&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want only what is after "&amp;amp;npseventname=" and before "&amp;amp;utm_campaign". I'd then want to unencode it to finally paste the result in another custom property.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 14:31:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/993825#M2385</guid>
      <dc:creator>JoshuaW</dc:creator>
      <dc:date>2024-06-18T14:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting Param Value From URL Path Using Custom Code</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/1119412#M2913</link>
      <description>&lt;P&gt;Hey Joshua,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for posting this and Karsten for the first step. I've come across this post as I was looking to do something similar and adapted code from another community post to push across the finish line:&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/9881-Operations-Hub/Custom-code-Format-Data-split-full-name-property/m-p/740086" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/9881-Operations-Hub/Custom-code-Format-Data-split-full-name-property/m-p/740086&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sharing here in case it's helpful for you or anyone else that stumbles across this post. Big disclaimer, I'm not an expert in any of this so it's possible that there's a better way to do it.. this is just what worked for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My use case: Extract utm_content from Last Page Seen&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Example Last Page Seen value: &lt;A href="https://yourdomain.com/" target="_blank" rel="noopener"&gt;https://yourdomain.com/&lt;/A&gt;?&lt;EM&gt;utm_source=example_source&amp;amp;utm_medium=example_medium&amp;amp;utm_content=content_type&amp;amp;utm_campaign=example_campaign&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Enrollment Filter: Last Page Seen contains utm_content&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Format data with regex_replace:&amp;nbsp;^.*utm_content=&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KKolodinsky_0-1741360572382.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/140417i712CCCA9CE70B6C6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KKolodinsky_0-1741360572382.png" alt="KKolodinsky_0-1741360572382.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Example output:&amp;nbsp;content_type&amp;amp;utm_campaign=example_campaign&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Custom code (Python 3.9)&lt;/P&gt;&lt;P&gt;Property to include in code: input_string = Action outputs - [String] value from step 1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KKolodinsky_1-1741360846674.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/140418i5C7F373E332386E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KKolodinsky_1-1741360846674.png" alt="KKolodinsky_1-1741360846674.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Use this code, customizing for your output field names&lt;/P&gt;&lt;PRE&gt;def main(event):&lt;BR /&gt;&lt;BR /&gt;content_string = event.get("inputFields").get("input_string")&lt;BR /&gt;&lt;BR /&gt;string_list = content_string.split("&amp;amp;")&lt;BR /&gt;&lt;BR /&gt;utm_content = string_list[0]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;return {&lt;BR /&gt;"outputFields": {&lt;BR /&gt;"utm_content": utm_content,&lt;BR /&gt;}&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KKolodinsky_2-1741360896273.png" style="width: 342px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/140419iCC9ADE32A44F64EC/image-dimensions/342x634?v=v2" width="342" height="634" role="button" title="KKolodinsky_2-1741360896273.png" alt="KKolodinsky_2-1741360896273.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Example output:&amp;nbsp;content_type&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Edit record, setting the property value to the string identified in 2. Custom code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KKolodinsky_3-1741361049460.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/140420i8A42FD3B93AE2463/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KKolodinsky_3-1741361049460.png" alt="KKolodinsky_3-1741361049460.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 15:31:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Extracting-Param-Value-From-URL-Path-Using-Custom-Code/m-p/1119412#M2913</guid>
      <dc:creator>KKolodinsky</dc:creator>
      <dc:date>2025-03-07T15:31:01Z</dc:date>
    </item>
  </channel>
</rss>

