Google Analytics: Tracking Custom URLs
Sometimes you want to know where a URL click comes from. Maybe you want to share an epa.gov link in an outreach instance, such as an email or a social media post, and you want to find out how many people follow that link. You can track those clicks by creating a unique URL with query strings.
- Create a URL containing a query string for the link you plan to share.
- Share that URL in an outreach campaign.
- Track clicks on that link in Google Analytics.
Create a URL Containing a Query String
A URL containing a query string might look like: https://www.epa.gov/?utm_source=facebook&utm_medium=social&utm_campaign=epamarketingQ1&utm_content=version2
- The user who clicks this link will simply go to the EPA homepage, but the rest of the URL will indicate where the click came from.
- You can then filter your GA data to target just that URL.
It might look complicated, but the above example was built using the following simple elements:
- Landing Page = www.epa.gov
- Source = facebook
- Medium = social
- Campaign = epamarketingQ1
- Content = version2
That means you shared this URL on social media, specifically a facebook post, as part of the second version of a campaign you decided to call "epamarketingQ1". And "campaign" is just a fancy way of saying "a time you shared a link to your site."
Tools for Building Your Query String
- Google Analytics Campaign URL Builder works like a form, where you fill in each element and it builds your query string.
- This is great for practice or if you only want to use query strings rarely, but if you plan to track more campaigns you should use the Excel spreadsheet option.
-
Spreadsheet for URL Building and Tracking (XLS) (xlsx)
: The advantage to using this tool is that you automatically have a place to save the URLs you create, and record what you learn from tracking them in Google Analytics.
- The formulas already loaded in the spreadsheet generate the query string for you as in the tool above, and it also includes instructions and examples for each element.
Share the Custom URL in a Campaign
You can add these custom URLs anywhere outside of epa.gov: emails, social media posts, etc.
Best Practices
- Note: only post custom URLs on non-epa.gov platforms; do not use this technique for tracking the use of a link on an epa.gov page. See Navigation To and From a Page: Which Links Get Clicked From Where for how to track clicks on links from epa.gov pages.
- Use a consistent, intuitive naming convention for each campaign, which clearly differentiates it from other campaigns.
Track Clicks on Your Link in Google Analytics
You can find click data on your campaigns and custom URLs in the Acquisition category of reports in Google Analytics.
You can see reports grouped by:
- Channel (email, social, etc.) or Source (facebook, govdelivery, etc.):

- Or by the name of your campaign:
- See Training Presentation: EPA Campaign Tracking with Google Analytics for further details and definitions.