How to automatically add UTM parameters in the links on your Shopify store
Urchin Tracking Module (UTM) parameters are five variants of URL parameters used by marketers to track the effectiveness of online marketing campaigns across traffic sources and publishing media. The UTM parameters in a URL identify the campaign that refers traffic to a specific website and attributes it to the browser’s website session and the sessions after that until the campaign attribution window expires. The parameters can be parsed by analytics tools and used to populate reports.
Actually, you must put the UTM parameters when set the links for each link. This article will helps you save time. It’s mean you can add the UTM parameters for all the links just 1 sec.
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code.
- In the Layouts directory, click
themes.liquid
to open it in the online code editor. - In the online code editor, add the below code before close </body> tag.1234567891011<script type='text/javascript'>$(document).ready(function(){$('a').each(function(){var href = $(this).attr('href');if(href.indexOf("?") > -1) href = href + "&";else href = href + "?";href = href + "utm_source=huratips.com&utm_medium=huratips.com&utm_campaign=huratips";$(this).attr('href',href);});});</script>
- Click Save and you are done.
Note: Remember to load jquery library first.
Actually, maybe you must change something in my code if you want work well with your case.