1. Opening Problem Statement
Meet Sarah, a digital marketing manager at East Coast Concrete Coating. Every week, she manually creates multiple UTM campaign links for Google Ads and email campaigns, generates QR codes for printed materials, and compiles Google Analytics reports to track campaign performance. This tedious process consumes at least 6 hours weekly and is prone to human error, such as misconfiguring UTM parameters or losing track of generated URLs. Inefficient tracking leads to incomplete data, making it hard for Sarah to evaluate campaign ROI or optimize advertising spend effectively.
This specific challenge of creating consistent UTM links, managing their storage, generating QR codes for offline use, and producing executive-level reports is exactly what this n8n workflow solves.
2. What This Automation Does
When you activate this workflow, here’s what happens automatically:
- Generates UTM-tagged URLs: Based on your campaign details, it builds consistent, error-free UTM links for your marketing channels.
- Stores URLs in Airtable: Automatically saves each created link in an Airtable base for central record keeping and easy access.
- Creates QR codes: Generates scannable QR codes from the created UTM links for offline marketing materials.
- Schedules Google Analytics reports: Periodically queries Google Analytics to retrieve session data and traffic sources linked to your campaigns.
- Uses AI for analysis: Employs an AI agent powered by OpenAI GPT-4 to analyze Google Analytics data, summarizing key campaign insights in an executive-friendly report.
- Emails reports: Sends the AI-generated analytics summary directly to your marketing manager’s Gmail inbox on a set schedule.
This workflow can save hours weekly, eliminate manual entry errors, and provide actionable insights to optimize marketing efforts.
3. Prerequisites ⚙️
- n8n account: Either cloud-hosted or self-hosted (Self-hosting options like Hostinger work well.)
- OpenAI API key: For the GPT-4 powered AI analysis.
- Google Analytics account: With access to the property ID you want to report on.
- Airtable account: For storing UTM links (Personal Access Token setup required).
- Gmail account: Configured with OAuth2 to send scheduled email reports.
4. Step-by-Step Guide to Set Up This Workflow
Step 1: Add a Manual Trigger to Start UTM Link Creation
Go to n8n, create a new workflow, and drag a Manual Trigger node onto the canvas named Create UTM Link & Send To Database. This node kicks off the process when you want to generate a new UTM link.
After saving, you’ll manually activate this trigger when entering new campaigns.
Common mistake: Forgetting to activate the workflow after setup.
Step 2: Set UTM Parameters Using a Set Node
Drag the Set node onto your canvas and connect it to the manual trigger node. Name it Set UTM Parameters For Link.
Define the following fields exactly as below (sample values from workflow):
website_url: https://ecconcretecoating.com/campaign_id: 12246campaign_source: googlecampaign_medium: displaycampaign_name: summerfuncampaign_term: conretecoating
These correspond to the standard UTM parameters.
What to expect: The node will prepare these values for the code node next.
Common mistake: Typo in parameters (e.g., campaign_term spelled wrong) will lead to incorrect URLs.
Step 3: Create UTM Link With Parameters Using a Code Node
Next, add a Code node named Create UTM Link With Parameters connected to the Set node. Use this exact JavaScript code:
const items = $input.all();
const updatedItems = items.map((item) => {
const utmUrl = `${item?.json?.website_url}?utm_source=${item?.json?.campaign_source}&utm_medium=${item?.json?.campaign_medium}&utm_campaign=${item?.json?.campaign_name}&utm_term=${item?.json?.campaign_term}&utm_content=${item?.json?.campaign_id}`;
item.json.utmUrl = utmUrl;
return item;
});
return updatedItems;
This code concatenates the UTM parameters into a full tracking URL.
Outcome: You get the final UTM URL appended in the output as utmUrl.
Common mistake: Missing question mark before parameters will create invalid URLs.
Step 4: Submit UTM Link To Airtable Database
Add an Airtable node named Submit UTM Link To Database. Connect it to the code node. Configure your Airtable base and table IDs. Map the utmUrl field to the URL column in your Airtable table.
What happens next: Each generated link is saved within your Airtable base for easy future reference.
Common mistake: Wrong base or table ID configured leads to data not saving.
Step 5: Generate QR Code from the UTM Link
Attach an HTTP Request node named Create QR Code With Submitted QR Link connected to the Airtable node.
Set the URL field to: https://quickchart.io/qr?text={{ $json.utmUrl }}&size=300&margin=10&ecLevel=H&dark=000000&light=FFFFFF
This sends a request to QuickChart.io to generate a QR code image from the UTM link.
Expected result: QR code image URL is returned in the node’s output.
Common mistake: Forgetting to include {{ $json.utmUrl }} in the URL text parameter yields wrong QR codes.
Step 6: Schedule Recurring Google Analytics Reports
Add a Schedule Trigger node named Schedule Google Analytics Report To Marketing Manager. Configure it to your desired timing (e.g., weekly or monthly).
This node initiates a scheduled Google Analytics data pull.
Tip: Weekly reports help quickly react to campaign performance changes.
Step 7: Query Google Analytics Metrics
Attach a Google Analytics node connecting from the schedule trigger. Configure it with your property ID and metrics like sessions and dimensions like sourceMedium.
This pulls recent traffic data related to your campaigns.
Common mistake: Incorrect property ID means no data fetched.
Step 8: Use AI Agent for Data Analysis and Reporting
Connect an Langchain Agent node named Google Analytics Data Analysis Agent to the Google Analytics node.
This node uses OpenAI’s GPT-4 to analyze the dataset and create a structured executive summary. In parameters, you’ll see a system message instructing the agent on the report format, focusing on KPIs and recommendations.
Expected output: A clear, concise marketing report summarizing campaign results.
Step 9: Send the Summary Report via Gmail
Add a Gmail node titled Send Summary Report To Marketing Manager connected to the AI agent.
Configure the Gmail node with OAuth2 credentials and set the recipient (e.g., [email protected]) and subject, as in the workflow.
The AI summary is emailed automatically according to your schedule.
Common mistake: Forgetting to allow Gmail API permissions for sending emails.
5. Customizations ✏️
- Change UTM parameters: In the Set UTM Parameters For Link node, update values like
campaign_mediumorcampaign_sourceto fit new campaigns. - Add more Google Analytics metrics: In the Google Analytics node, include conversion or bounce rate metrics for deeper insights.
- Modify report frequency: Adjust the Schedule Trigger node interval to daily, weekly, or monthly to suit your reporting needs.
- Use a different QR code provider: Replace the URL in the HTTP Request node to another QR code generation API if desired.
- Change email recipient: Update the Gmail node’s recipient email to target different team members.
6. Troubleshooting 🔧
Problem: “No data returned from Google Analytics node.”
Cause: Incorrect Google Analytics property ID or OAuth credentials.
Solution: Verify property ID in the node settings and ensure your Google OAuth2 credentials have sufficient permissions.
Problem: “Airtable data not updated or missing records.”
Cause: Base or table ID misconfigured or API token permissions.
Solution: Double-check Airtable base/table IDs and permissions provided to the API token.
Problem: “QR code image not generated or wrong URL.”
Cause: Improper dynamic parameter passed in HTTP request URL.
Solution: Ensure {{ $json.utmUrl }} is correctly inserted and URL encoded if needed.
7. Pre-Production Checklist ✅
- Test manual trigger to verify UTM link generation outputs the correct URL.
- Verify Airtable record creation and presence of the stored UTM URL.
- Scan generated QR code to confirm the link correctly directs to the campaign page.
- Check scheduled trigger runs and Google Analytics data pulls.
- Validate AI-generated summaries for clarity and relevance.
- Send test email via Gmail node and confirm delivery to recipient inbox.
8. Deployment Guide
Activate the workflow in n8n by switching it to active mode. This enables the schedule trigger and manual trigger for real use.
Monitor the workflow executions from the n8n dashboard to check for errors or missed runs. Enable error notifications if needed to promptly address any failures.
Review Airtable storage and email reports regularly to ensure the system runs smoothly. Adjust scheduling or parameters as campaigns evolve.
9. FAQs
Q: Can I use a different database instead of Airtable?
A: Yes, you can swap out the Airtable node with other database nodes like Google Sheets or MySQL, but you’ll need to adjust field mappings accordingly.
Q: Does this workflow consume a lot of OpenAI API credits?
A: The AI agent queries once per scheduled report, so usage is moderate and scales with your reporting frequency.
Q: Is my data safe in this workflow?
A: Yes, all data transmissions occur over secure APIs with OAuth2. Sensitive data is stored only within your Airtable base.
Q: Can I handle large volumes of UTM links?
A: This workflow is scalable within n8n limits, but very high volume may require workflow optimization or splitting into batches.
10. Conclusion
By setting up this n8n workflow, you’ve automated one of the most labor-intensive parts of digital marketing: creating and managing UTM campaign links alongside QR codes for offline use, while scheduling insightful Google Analytics reports. Sarah’s time investment drops from multiple hours weekly to just a few minutes of oversight.
This automation improves accuracy, record keeping, and delivers clear, AI-enhanced insights straight to your inbox, enabling smarter marketing decisions.
Next, you might consider expanding with automated social media posting for each campaign or integrating lead capture forms to feed campaign tracking in real-time.
You’re now equipped to save time, reduce errors, and boost campaign ROI — all with a friendly, beginner-accessible n8n workflow!