{"id":"code-work-mkt-utm-link-formula","audience":"marketing","category":"coding","track":"coding","technique":"format","title":"Build tagged campaign links with one sheet formula","free":false,"task":"Write a Google Sheets formula for E2 (filled down to E500) that builds the tracking link from A2 (page URL), B2 (source), C2 (medium) and D2 (campaign) as utm_source, utm_medium, utm_campaign in that order. Rows with an empty A must stay blank. Where a URL already contains a ?, join the tags with & instead. The campaign must come out lowercase with spaces turned into hyphens, because analytics splits Spring Sale and spring-sale. One formula in one code block, then under 20 words outside the code.","materialLabel":"Campaign link sheet (attached to your prompt automatically)","material":"SPRING LINKS sheet - Fernwood Outdoor (row 1 is headers)\nA Page URL | B Source | C Medium | D Campaign | E Tracking link\nhttps://fernwood.example/boots | newsletter | email | Spring Trail Sale | ?\nhttps://fernwood.example/tents?color=green | instagram | social | Spring Trail Sale | ?\nhttps://fernwood.example/sale | partner_blog | referral | Camp Week 2026 | ?\nhttps://fernwood.example/packs?size=40l&ref=nav | newsletter | email | Camp Week 2026 | ?\n(rows 6-500 are empty, ready for next month)\n\nNotes from Tess:\n- We tried a link-builder website but it didn't work in bulk.\n- Partner blog links go out on Tuesdays.\n- Sources and mediums are already lowercase.\n- Instagram links go in the bio tool, not the posts.","rules":[{"type":"codeBlocks","count":1},{"type":"maxProseWords","max":20}],"mistakes":[{"title":"Forgetting the empty rows","why":"The AI's formula fills hundreds of blank rows with half-built links.","fix":"Add: \"If A2 is empty, return blank.\"","checks":["r0"]},{"title":"Not mentioning existing ?","why":"The AI always adds ?utm_source=, which breaks links that already have a question mark.","fix":"Add: \"If A2 already has a ?, join with & instead.\"","checks":["r1"]},{"title":"Not setting the case rule","why":"The AI copies the campaign as typed, so capitals and spaces split your analytics.","fix":"Add: \"Campaign lowercase, spaces turned into hyphens.\"","checks":["r2"]},{"title":"Getting a menu of options","why":"The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself.","fix":"Add: \"Give one formula only, in one code block, no alternatives.\"","checks":["codeBlocks"]},{"title":"Getting a tutorial","why":"By default the AI explains every part of the code at length, which you then have to scroll past.","fix":"Add: \"After the code, one line under 12 words. Nothing else.\"","checks":["maxProseWords"]}],"promptHints":[{"label":"Keeps empty rows blank","patterns":["blank","empty"]},{"label":"Handles URLs with a ?","patterns":["already (has|contains)","\\?","find\\("]},{"label":"Sets the campaign format","patterns":["lower","hyphen","dash"]},{"label":"Asks for one answer only","patterns":["\\b(one|single|1)\\s+(formula|code block|block|version)","only one","no (alternatives|options|other versions)"]},{"label":"Limits the explanation","patterns":["\\d+\\s*words","no (explanation|notes|commentary)","one (short )?(line|sentence)","nothing else"]}],"hint":"Look at the URLs closely and at the empty rows below them. Tell the AI how to handle both and how the campaign name should look.","rubricLabels":["Returns a blank (\"\") when A2 is empty, for example IF(A2=\"\",\"\",...), so unused rows stay empty","Uses & instead of ? before the tags when A2 already contains a ? (checked with FIND or REGEXMATCH), and adds utm_source, utm_medium and utm_campaign from B2, C2 and D2 in that order","Makes the campaign lowercase with spaces replaced by hyphens (LOWER and SUBSTITUTE on D2), so \"Spring Trail Sale\" becomes spring-trail-sale"]}