Back to Blog
Automation Workflows

How to Build an Automated UTM Link Builder with n8n, Google Sheets, and Bitly

n8n
n8n Resources Team
April 16, 2026

The Problem with Manual UTM Tracking

For any marketing team, consistent and accurate campaign tracking is non-negotiable. Urchin Tracking Module (UTM) parameters are the industry standard for measuring the effectiveness of digital marketing efforts. But the process of creating them is often a tedious, manual bottleneck.

Someone on your team likely opens a spreadsheet, copies a target URL, and then painstakingly adds ?utm_source=...&utm_medium=...&utm_campaign=.... After that, they probably paste this long, clunky URL into a shortener like Bitly. This manual process is not only slow but also ripe for human error—a single typo in a campaign name can corrupt your analytics data, making it impossible to attribute revenue or leads correctly.

This workflow solves that problem. By connecting Google Sheets, n8n, and Bitly, you can create a fully automated system that generates consistent, error-free, and shortened tracking links the moment you define a new campaign.

Why You Should Automate UTM Generation

Automating this process isn't just a convenience; it's a strategic move to improve your marketing operations:

  • Enforce Consistency: Guarantee every link follows your exact naming conventions, leading to cleaner and more reliable analytics.
  • Eliminate Errors: Remove the risk of typos or copy-paste mistakes that can break your tracking.
  • Increase Efficiency: Free up your marketing team from a repetitive, low-value task so they can focus on strategy and creative work.
  • Centralize Your Links: Maintain a single source of truth in Google Sheets with all your campaign parameters and their corresponding short links.

Your Automation Toolkit

To build this workflow, you'll need accounts for three services. You can start with the free tiers for all of them.

  1. n8n: The core of our workflow. This is the automation engine that will connect our tools and execute the logic. You can use n8n Cloud or a self-hosted instance.

  2. Google Sheets: Our trigger and database. We will use a simple sheet to input campaign details and store the final shortened URL.

  3. Bitly: Our URL shortening service. The Bitly API allows us to programmatically shorten links generated by our workflow.

Example n8n Workflow: Building Your Automated UTM Link Generator

This workflow triggers whenever a new row is added to a specific Google Sheet, builds a full URL with UTM parameters, shortens it via the Bitly API, and then writes the short link back to the same row in the sheet.

The final workflow in n8n will look like this:

Google Sheets Trigger -> Set Node -> Bitly Node -> Google Sheets Node

Step 1: Set Up Your Google Sheet and Trigger

First, create a new Google Sheet that will act as your campaign input form. The header row is critical, as n8n will use these names as variables.

Create the following columns:

  • Target URL: The base URL you want to send traffic to (e.g., https://my-website.com/landing-page).

  • utm_source: The source of the traffic (e.g., google, facebook, newsletter).

  • utm_medium: The marketing medium (e.g., cpc, social, email).

  • utm_campaign: The specific campaign name (e.g., q4-sale-2026).

  • utm_content (Optional): To differentiate ads or links within the same campaign.

  • utm_term (Optional): To identify paid search keywords.

  • Short Link: This column will start empty. Our workflow will populate it.

  • Status: We'll use this to prevent the workflow from running on the same row twice.

In n8n, create a new workflow and add the Google Sheets Trigger node.

  1. Connect your Google Account credentials.
  2. In the Sheet ID field, select the Google Sheet you just created.
  3. In the Sheet Name field, choose the specific tab.
  4. The trigger will now fire every time a new row is added to this sheet.

Step 2: Construct the Full URL with a Set Node

Now we need to assemble the final URL from the data in our sheet. Add a Set node after the Google Sheets Trigger.

This node creates new variables or modifies existing ones. We will create a new variable called longUrl.

  1. Click 'Add Value' and select 'String'.
  2. Set the Name to longUrl.
  3. For the Value, we will use an n8n expression to piece together the URL. This expression dynamically pulls data from the trigger node.

Your expression will look like this:

{{$json["Target URL"]}}?utm_source={{$json["utm_source"]}}&utm_medium={{$json["utm_medium"]}}&utm_campaign={{$json["utm_campaign"]}}

This expression takes the Target URL and appends the source, medium, and campaign parameters from the columns in your sheet. You can extend it to include utm_content and utm_term if you use them.

Step 3: Shorten the Link with the Bitly Node

With our long, UTM-tagged URL constructed, it's time to shorten it.

  1. Add a Bitly node to your workflow.

  2. Create new credentials by following the prompts to connect your Bitly account. You'll need to grab your API access token from your Bitly account settings.

  3. Set the Resource to Link and the Operation to Shorten.

  4. In the Long URL field, insert the variable we created in the previous step by using the expression: {{$node["Set"].json["longUrl"]}}.

When this node runs, it will send the longUrl to Bitly and receive a shortened link in return.

Step 4: Write the Short Link Back to Google Sheets

Finally, we need to close the loop by adding the new short link and updating the status in our original Google Sheet.

  1. Add a Google Sheets node (not the trigger node).

  2. Set the Operation to Update Row.

  3. Select the same Sheet ID and Sheet Name as in your trigger.

  4. For the Row Index, you need to tell n8n which row to update. The Google Sheets trigger provides a rowIndex property. Use the expression {{$node["Google Sheets Trigger"].json["rowIndex"]}}.

  5. Under Columns, add the columns you want to update. Add a field for Short Link and map its value to the output of the Bitly node: {{$node["Bitly"].json["link"]}}.

  6. Add another field for Status and set its value to a static string like Processed. This prevents the workflow from accidentally re-triggering on already processed rows if you later modify them.

Activate your workflow, and you're done! Now, anytime someone adds a new row with campaign details to the Google Sheet, n8n will automatically generate the UTM link, shorten it, and paste it back into the sheet within seconds.

Taking the Workflow to the Next Level

This core workflow is incredibly powerful, but you can easily extend it for more complex use cases:

  • Add Error Handling: What if the Bitly API is down? Add an IF node after the Bitly step to check for a successful response. If it fails, route the workflow to send a notification to a Slack channel or an email address.
  • Integrate a Form: Instead of having your team enter data directly into Google Sheets, use a tool like Typeform, Tally, or Jotform as the trigger. This provides a more user-friendly interface and can include data validation.
  • Generate QR Codes: Add another step after the Bitly node that sends the new short link to a QR code API. You can then save the generated QR code image to Google Drive and add its link to your sheet.

Enjoyed this article?

Share it with others who might find it useful