Thanks for these questions, Justin. And for the extraordinary detail, you continue to provide fantastic reflections of this process and it seems apt to explain the flow in which this is embedded.
We have (1) an Artable form with a rich text field that collects the contents of an email to be sent, (2) a zap that converts that rich text to HTML, and (3) this intended formula for adding a UTM code to each URL within the submitted text (the number of URLs per message varies greatly).
For us, the most important element of the UTM is the term= (adding what’s between ">TEXT</a> to the end of the UTM) as this is what shows up in our real-time viewer.
For example, this HTML with two URLs:
<p>Let's sync at <a href="https://mythos.one/brianswichkow/7f2fd4">Cooperative Currency</a>.</p><p><a href="https://mythos.one/brianswichkow/0b480c">John Zdanowski</a> is hosting the space at 3:45 PM today.</p>
Would become this HTML with UTMs added to each:
<p>Let's sync at <a href="https://mythos.one/brianswichkow/7f2fd4?utm_source=BrianPlus&utm_medium=Email&utm_campaign=One%20Gathering&utm_term=Cooperative%20Currency">Cooperative Currency</a>.</p><p><a href="https://mythos.one/brianswichkow/0b480c?utm_source=BrianPlus&utm_medium=Email&utm_campaign=One%20Gathering&utm_term=John%20Zdanowski">📝John Zdanowski</a> is hosting the space at 3:45 PM today.</p>
We do this elsewhere. At present, I’m not seeing how to (a) multiple links of an unknown quantity from the source text or HTML and (b) add the term= field of the UTM using the linked text.
Turning
">THIS TEXT</a>
Into
&utm_term=THIS%20TEXT">THIS TEXT</a>
Thank you so much again for your help.
~Brian
Thanks for the further clarification, Brian. That confirms what I suspected based on that most recent screenshot you posted. The biggest problem is this:
Unfortunately Airtable doesn’t have any support in its formula fields for operating on arbitrary quantities of things. It’s great with fixed quantities, but once it becomes variable, it becomes a lot more difficult to process in a formula, especially if each instance needs unique treatment.
My next suggestion is to look into writing a custom script in the Scripting block. Those scripts are written in JavaScript, which has much more robust features for text parsing and iteration through arbitrary collections. The downside is that you would need to manually run this block whenever you’ve got new records that haven’t been tweaked, but it could be made smart enough to only process each record once, skipping over those that already have the UTM info added.
If you’d like assistance with writing code for the Scripting block, I suggest posting in the #developers:work-offered category, perhaps linking back to this post so people can see what needs to be done. (I would offer my own services, but my JavaScript is still a tad rusty, and there are definitely folks here who would get you the code you need much faster than I could. :slightly_smiling_face: )