text: Link Tracking In-Depth for Digital Marketers - The Startup - Medium
  Aim high — link tracking is not rocket science.
  The essence of link tracking is to measure the amount of traffic one source drives to a destination, through a link. To be able to leverage the power of what is possible, it is critical to understand the fundamentals.
  I can't stress this enough. At countless times, the source of confusion has been due to not understanding how an existing link may be modified or what a redirect is.
  Let's start with the basics of what a link and an URL, and then cover the different methods to track a click, and finally how they work and where to use them. I've included a couple of pro-tips in the article. These tips may be more advanced, but they will set you apart as a marketer.
  A link in HTML with a href attribute containing a URL
  A link is a reference to something the user can directly follow by, typically, clicking or tapping on it. The actual web address pointing to that other thing-on-the-internet is a URL (Uniform Resource Locator). However, most often the terms link and URL are used interchangeably.
  The URL is the most fundamental part of link tracking to understand. If you learn what a URL is and its format, then you'll have no problems modifying it however you want for your own needs (as seen later, this will be necessary).
  The illustration shows the format of a typical URL. Here is an overview of the different parts.
  Protocol. For a web address, this is typically https or http (where https require that requests are made over a secure connection).
  Host. Often the host is what we refer to as the website address. Consists of an optional subdomain, domain name and top-level domain (for example .com or country-code)
  Path. An optional path, starting with a slash /, typically determines which web page of the website to show.
  Parameters. The optional parameters (also called query string) are preceded by a question mark. Parameters are sent to the host in the form of attribute-value pairs separated by an ampersand &.
  Fragment. The last part is the fragment preceded by a hash #. The fragment is commonly used to have the browser automatically scroll to a specific part of the web page (also referred to as a named anchor).
  When a user follows a link, the user's web browser performs a request to the host, requesting the data on the specified path with the supplied parameters. The host responds with data instructing the user's web browser what to do (typically showing a web page, or redirecting to a new URL).
  Modifying a URL and its parameters
  For link tracking, it is usually the query string with its attribute-value pair parameters that you may end up modifying. Typical scenarios may be that you need to add extra parameters like UTM codes (sometimes called UTM tags), or a parameter of your own to ensure the URL is unique.
  We'll dive into what UTM codes are and other use cases later. What is important to remember is that in almost* all cases there is no harm in adding extra parameters. What you need to understand the format of the URL and how to add parameters.
  * Theoretically, a web page may be so poorly implemented that it fails to show because of an unexpected parameter, but this should not be a concern.
  There is always a question mark separating the path and the query string.
  Parameters are in the form attribute=value
  Separate multiple parameters with an ampersand &
  You can add a made-up parameter without affecting anything
  Parameter structure of an URL (line breaks inserted for clarity)
  As an example, we want to add the parameter utm_source with the value medium to these two links.
  In the first example we just got a full domain name, so we need to add the question mark to append an additional parameter.
  https://relatable.me becomes https://relatable.me?utm_source=medium
  In the second example, the URL already contains a parameter. Hence we use the ampersand as a separator to append the other one.
  https://careers.relatable.me/?id=123 becomes https://careers.relatable.me/?id=123&utm_source=medium
  Make sure to copy/paste the changed URL and try it out in a browser to ensure everything works as expected.
  Let's look at what a click (or tap, for mobile devices) is from a technical point of view in a web browser, then we can understand how, and where, we can measure it.
  1. When the user clicks on a link, the browser triggers a signal that something has happened — an event. More specifically the mouse event click.
  2. The browser checks if there is any handler — a piece of JavaScript programming code that is run when a particular event is triggered.
  3. If there is a handler, the handler code is executed. If the handler is not preventing it, the browser continues by looking at what URL to open next.
  4. The browser requests the data from the URL and looks in the part of the response called header. If the header is not telling the browser to go to another URL (redirect) the browser continues to parse the body of the response to show the content of the destination in the browser.
  5. The browser loads the destination page and any resources required (images, stylesheets, JavaScript code, and more) to show the web page in the browser. It does also execute any JavaScript code on load.
  When a link is displayed in an app instead of in a browser the first three steps are skipped, and a browser is opened to request the URL directly.
  Now we understand what is happening and can dive into how we can keep count and track clicks.
  There are three main ways to track a click.
  Click Event: Using the handler to listen on the click of the link on the website.
  Redirect: Have the link go to a host (typically a URL shortener) that counts the click and then redirects the user to the final destination.
  Page Load: Track the request on the destination website. This is what you do to track incoming traffic to your own website.
  Before diving deeper into each method, let's sum it up: use click events to track outgoing links on your website, use redirects to track clicks on links you share, and upon page load for incoming traffic to your website.
  To track click events on a web page, you need to have access to the website source code, either directly or through something like Google Tag Manager. Hence, this solution is typically only used to track outgoing links on your own website. It is not possible to use this method to track links on Instagram, in YouTube video descriptions, on Twitter and so on.
  Google Analytics accomplishes this by intercepting the click event, count the click for the particular URL, and then let the browser open up the new page. See the Google Analytics support pages for details of how to implement this.
  Making use of redirects is perfect when you have no control over where the link is used, and no control of the destination website. A typical use case is when driving traffic to a client website using social media.
  The most common way to use the redirect mechanism for click tracking is by using a URL shortener. Bitly is the most popular one, but the basic concept of them all is the same — map a long URL to a shorter one.
  As an example, at Relatable I want to share our guide The A to Z of Influencer Marketing on Instagram using UTM-parameters. The URL becomes quite long:
  https://www.relatable.me/a-z?utm_source=instagram&utm_medium=cpc&utm_campaign=stpe
  Putting the URL through Bitly, we get https://bit.ly/2N1x3VP — much more convenient to use in a website link in an Instagram profile.
  Bitly accepts a URL and creates a unique short name for that particular link — a bitlink. When a bitlink is clicked, the user's browser makes a request to the Bitly host, that count it as a click and looks up the long destination URL and redirects the user's browser there.
  User clicks the link, is redirected to Bitly that count a click and redirects to the destination.
  It is easy to check the click statistics of any bitlink is to append a +-character to the URL https://bit.ly/2N1x3VP+, try it! Keep in mind that the statistics are publicly available to anyone.
  Note that the same URL will always return same shortened bitlink. This is a problem when you want to see how many clicks different sources generate to the same destination. The solution is in the next section.
  Pro-tip: It is possible that a URL redirects to another that will redirect, and so on. To see the complete chain of redirects, open your Terminal (macOS) and use the curl command:
  curl -sI -L http://bit.ly/2IOKsLf | grep 'Location:'
  We can add a parameter with a unique value to the URL to make it unique. Using our knowledge from the section Modifying a URL and its parameters above, we know how to do this. This parameter could be anything, as long as it is unique, but often it may make sense to use a UTM parameter.
  Example; we want several different persons to use their social media accounts to get potential candidates to our job page as Software Developer. The URL is:
  https://careers.relatable.me/jobs/46522-full-stack-web-developer
  To get different Bitly links we add the made-up parameter person and assign it the value of each person's name (could also be a made-up value as long as it is different).
  https://careers.relatable.me/jobs/46522-full-stack-web-developer?person=sirihttps://careers.relatable.me/jobs/46522-full-stack-web-developer?person=roberthttps://careers.relatable.me/jobs/46522-full-stack-web-developer?person=annikaand so on...
  Using these URLs, we get different Bitly links so we can tell how many clicks each person's link got, even if they all go to the same destination.
  Pro-tip: If you want to get advanced, I've written another article about how to leverage the Bitly API for automating link tracking, both for creating shortened links and retrieving statistics (no programming skills needed).
  Technically there is nothing that prevents the host you redirect to, to select the destination URL based on certain conditions. Different destination depending on the time of day, or even randomly select the destination from a list of URLs.
  The most common use case for dynamic redirects is when linking to a mobile app. This is how it works.
  When a request is made a string of text called a User-Agent is supplied. It contains information about the browser and device that makes the request. Using an iPhone and Safari, it does look like this:
  Using an Android phone, it may look like this:
  As highlighted in bold, there are differences that the may be used to determine type operating system. If iPhone then redirect to App Store, if Android then redirect to Google Play Store, if neither — then redirect to a webpage as a fallback.
  One such free provider that supports dynamic redirects for mobile apps Onelink.to.
  If you are in control of the destination website you can use Google Analytics to track incoming requests. The will show up under the Acquisition section, and you can drill down deeper to look at referrals to determine where the requests are coming from.
  The problem is that for a lot of requests there is no way to determine the referrer; instead, they're all counted as Direct traffic. Direct does not necessarily mean the user typed in the URL in their browser — it does mean that the referrer field in the request is missing or empty. Referrer may be missing when an app opens a URL, for example, the Instagram app.
  This is addressed by using UTM parameters.
  Instead of having incoming request show up as direct traffic without any further context in Google Analytics, you can use the special UTM parameters to override these values.
  You don't need to use all UTM parameters, they are optional. There are no right or wrong values, but it is good to stick to a convention that will make it easier to analyze your incoming traffic.
  The convention is to use utm_source to describe where traffic is originating from, for example, facebook or medium. utm_campaign is used to determine if the link is part of a campaign or similar marketing effort. utm_medium may be used to separate different methods, like link_in_bio or banner.
  Values do not need to be "registered" anywhere in advance. If a new value is introduced, it will simply show up in Google Analytics.
  For assistance creating UTM parameters, using Google's Campaign URL Builder is highly recommended.
  Note that UTM parameters are visible to anyone — don't use values you don't want to be seen.
  I hope this guide has been useful and you are much more confident in navigating the landscape of link tracking. Please write a comment if you have any questions, or found this article helpful — I will do my best to respond.
  Relatable is a marketing tech company specialized in influencer marketing. Through clever use of technology and automation, we create large-scale word of mouth marketing with the most creative and influential people around the world. Check out our current job openings to join us, or our case studies for examples of what we do.