Xerobit

UTM Builder: Tag Your Campaign URLs

A UTM builder appends campaign tracking parameters to any URL so analytics platforms can attribute traffic correctly. Enter your base URL and fill in the UTM fields to generate a tagged link instantly. This campaign URL builder runs entirely in your browser, so no data is uploaded anywhere.

Converts parameter values to lowercase for consistent reporting.

Tagged URL

https://example.com/?utm_source=google&utm_medium=cpc&utm_campaign=spring_sale
  • Tagged URL
    https://example.com/?utm_source=google&utm_medium=cpc&utm_campaign=spring_sale
  • utm_source
    google
  • utm_medium
    cpc
  • utm_campaign
    spring_sale

How UTM Parameters Work

UTM (Urchin Tracking Module) parameters are key-value pairs appended to a URL after a question mark. When a visitor clicks the link, analytics tools read these parameters and attribute the session to the correct source, medium and campaign.

The five standard parameters are:

  • utm_source: where the traffic originates (e.g., google, newsletter).
  • utm_medium: the marketing channel (e.g., cpc, email, social).
  • utm_campaign: the specific promotion or product name.
  • utm_term: the keyword for paid search ads.
  • utm_content: differentiates multiple links on the same page or ad variations.

An optional sixth parameter, utm_id, carries a campaign ID, which GA4 reads as the campaign ID dimension.

Building the Query String Correctly

A common mistake when using a campaign URL builder is overwriting existing query parameters or placing UTM tags before the URL fragment. The correct structure follows RFC 3986:

scheme://host/path?existing=params&utm_source=x&utm_medium=y#fragment

If the base URL already contains a question mark, new parameters must be joined with an ampersand (&). If there is no question mark, the first UTM parameter starts with one. The fragment identifier (the part after #) must always remain at the very end of the URL, because browsers do not send fragments to the server and placing parameters after a fragment breaks tracking.

This UTM link builder handles that logic automatically. It parses the input URL, separates the fragment, checks for existing query parameters, appends only non-empty UTM fields, percent-encodes special characters like spaces and ampersands, replaces any UTM parameter of the same name that is already in the URL, and reattaches the fragment. A bare domain such as https://example.com gets its implicit / path.

GA4 and HubSpot Compatibility

Both Google Analytics 4 and HubSpot rely on the same standard UTM parameters. A GA4 UTM builder does not use a different format than a HubSpot UTM builder; they both read utm_source, utm_medium and utm_campaign from the incoming URL.

The difference lies in how each platform reports the data. GA4 groups traffic into default channel groupings based on combinations of source and medium. For example, a source of google and a medium of cpc maps to "Paid Search". HubSpot records the same UTM values on contacts and sessions so you can report on them next to its own source properties.

To ensure compatibility across both platforms, keep your naming conventions consistent. Use lowercase values, avoid spaces (use underscores or hyphens instead), and never reuse the same campaign name for different channels.

Common UTM Naming Conventions

Inconsistent naming is the primary reason campaign data becomes fragmented in analytics reports. Below is a reference table of recommended conventions:

ParameterRecommended FormatExample
utm_sourcelowercase, no spacesfacebook, mailchimp
utm_mediumlowercase, standard termscpc, email, social, referral
utm_campaignsnake_case or kebab-casesummer_sale_2024, q3-launch
utm_termlowercase, words joined with a hyphen or underscorerunning-shoes
utm_contentdescriptive, lowercaseblue_button, text_link_v2

Using the lowercase option in this tool enforces the first rule automatically, preventing duplicates caused by mixed casing like Google versus google.

Verifying URLs Programmatically

After generating links with a UTM builder, you can verify them programmatically. In Python, the urllib.parse module makes this straightforward:

from urllib.parse import urlparse, parse_qs
parsed = urlparse(tagged_url)
params = parse_qs(parsed.query)
print(params.get('utm_source'))

This confirms that the parameters were attached correctly and that the fragment was not corrupted. You can also paste the final URL into a tool like the URL encoder to inspect how special characters are percent-encoded.

Worked examples

ExampleInputResult
Basic GA4 campaignBase URL: https://example.com/landing; utm_source: google; utm_medium: cpc; utm_campaign: spring sale; Lowercase all values: yesTagged URL: https://example.com/landing?utm_source=google&utm_medium=cpc&utm_campaign=spring%20sale; utm_source: google; utm_medium: cpc; utm_campaign: spring sale
Newsletter with existing queryBase URL: https://shop.example.com/?ref=sidebar; utm_source: newsletter; utm_medium: email; utm_campaign: weekly_digest; utm_content: header_link; Lowercase all values: yesTagged URL: https://shop.example.com/?ref=sidebar&utm_source=newsletter&utm_medium=email&utm_campaign=weekly_digest&utm_content=header_link; utm_source: newsletter; utm_medium: email; utm_campaign: weekly_digest; utm_content: header_link
HubSpot style with IDBase URL: https://example.com/pricing; utm_source: HubSpot; utm_medium: Social; utm_campaign: Q3_Promo; utm_id: camp_99; Lowercase all values: noTagged URL: https://example.com/pricing?utm_source=HubSpot&utm_medium=Social&utm_campaign=Q3_Promo&utm_id=camp_99; utm_source: HubSpot; utm_medium: Social; utm_campaign: Q3_Promo; utm_id: camp_99
URL with fragmentBase URL: https://example.com/page#top; utm_source: twitter; utm_medium: social; utm_campaign: launch; Lowercase all values: yesTagged URL: https://example.com/page?utm_source=twitter&utm_medium=social&utm_campaign=launch#top; utm_source: twitter; utm_medium: social; utm_campaign: launch

FAQ

What is a UTM builder?

A UTM builder is a tool that appends Urchin Tracking Module parameters to a URL. These parameters tell analytics platforms where a visitor came from, what marketing medium delivered them and which campaign they belong to.

Do I need a different tool for GA4 versus HubSpot?

No. Both GA4 and HubSpot read the same standard UTM parameters. A single campaign URL builder works for any analytics or CRM platform that supports UTM tracking.

Which UTM parameters are required?

At minimum, you should include utm_source, utm_medium and utm_campaign. The utm_term, utm_content and utm_id parameters are optional and used for more granular tracking.

Why should I lowercase UTM values?

Analytics platforms treat uppercase and lowercase as distinct values. Lowercasing prevents duplicate entries, such as counting "Email" and "email" as two separate mediums in your reports.

Will this break my existing URL parameters?

No. This UTM link builder keeps your existing query string parameters and the fragment identifier at the end. It only appends the UTM fields, and if the URL already contains a UTM parameter with the same name, the new value replaces it so the link never carries two values.

Is my data sent to a server?

No. The URL construction happens entirely in your browser using JavaScript. Nothing is uploaded or stored.

Can I use spaces in UTM values?

You can type spaces, and the tool will percent-encode them automatically. However, it is better practice to use underscores or hyphens to keep URLs readable and avoid encoding issues in some older systems.