<aside> 💡 Notion Tip: Use this template to automate the process of generating UTM links with formulas!

Fill in the Original URL, Source and any other parameters to specify their values for your link. Hover over the UTM link column’s output to copy the link it generates.

</aside>

UTM Builder


How the formula works

The formula checks for errors, and then generates a UTM link based on the specified UTM parameters. It is written out below 👇

ifs(
	/* Check that the Original URL is filled in */
	empty(prop("Original URL")),
	"Please add a URL".style("blue", "b"),
	
	/* Check that the Source is filled in */
	empty(prop("Source")),
	"Error: UTM requires a source".style("red", "b"),
	
	/* Check that there are no blank spaces in the URL or parameters */
	(prop("Original URL")+prop("Source")+prop("Medium")+prop("Campaign")+prop("Term")+prop("Content")).contains(" "),
	"Error: URL or a parameter can not contain spaces".style("red" , "b"),
	
	let(
		/* Store a variable named "URL" to use to generate link */
		URL,
		
		/* Generate the UTM url; if a parameter isn't specified, don't include it */
		prop("Original URL") +
			if(not empty(prop("Source")), "?utm_source=" + prop("Source"), "") +
			if(not empty(prop("Medium")), "&utm_medium=" + prop("Medium"), "") +
			if(not empty(prop("Campaign")), "&utm_campaign=" + prop("Campaign"), "") +
			if(not empty(prop("Term")), "&utm_term=" + prop("Term"), "") +
			if(not empty(prop("Content")), "&utm_content=" + prop("Content"), ""),
		
		/* Genrate clickable and copiable link */
		URL.link(URL)
	)
)