Track user source/medium flow using server Google Tag Manager

Feb 5, 2022
Nov 30, 2021
Also available in

Google Analytics offers a variety of reports allowing you to examine user behavior. The most frequently used report when analyzing conversions is exploring source/medium. When configured correctly, this type of report gives valuable insights on which traffic sources bring in more users and conversions.

Google Analytics has a lot of different models for how to attribute conversions. Still, the default model is last click non-direct traffic, which means conversion will be attributed to the most recent non-direct traffic source. Though this type of attribution model can be relevant for some websites, it may not be accurate for others (especially websites with high average order value) since users have multiple interactions before purchasing on the site. And the last traffic source may not have the most significant role in a user’s decision to buy your product. 

Stape created the Channel Flow tag for the server Google Tag Manager that helps track all user interactions with the site. In this post, I want to talk about using Server GTM to track the user’s first, last source/medium, and all interactions in between.

How does the Channel Flow tag for the server GTM works?

The logic of our Channel Flow tag is straightforward. It records users’ first, last, and all middle interactions in the browsers’ cookies. 

  • Channel_flow - records the source/medium flow of all user interactions with the site
  • Channel_flow_first - records the first source/medium
  • Channel_flow_last - records the last source/medium
ads user channel flow in cookies

Channel flow tag configurations:

URL Source - defines a variable that contains a URL. You can select page_location to use URL from Common Event Data or provide a variable that returns a valid URL string.

Referrer Source - defines a variable that contains Referrer. You can select page_referrer to use Referrer from Common Event Data or provide a variable that returns a valid Referrer URL string.

Search Engines Regular Expression - you can modify this reg exp to include or exclude organic traffic sources.

Cookie lifetime - Channel Flow cookies expiration in seconds (set 0 for session cookie). 2 years by default.

How can you use the Channel Flow tag?

There might be multiple use cases for the channel flow tag, but initially, we created this tag to help measure affiliate conversions and assign affiliate commission appropriately. But then we realised that the channel flow tag could be used in several other ways, like Google Analytics and CRM. I'm sure there are tons of different use cases!

Affiliate conversion win

Let’s say you work with several affiliate partners or have offers in multiple affiliate networks. Who should receive a commission if two affiliates participated in one conversion flow? Should you split the commission between the two of them? How to determine whose interaction was the first one and whose the last? 

No matter what rules for assigning affiliate commission you have, a channel flow tag can help. You can use the channel flow tag to determine what affiliate wins the conversion based on their positions in the channel flow.

Affiliate commission rate

Another scenario when the channel flow tag helps is assigning commissions based on the affiliate's position in the conversion interaction path. For example, when two affiliates participate in the conversion path, you might want to assign 80% of the commission to the last interaction, while the rest of the commission should go to another affiliate. 

Track initial traffic source in Google Analytics

The default Googles Analytics attribution assigns conversion to the last click non-direct traffic source. This information might not be enough when evaluating the effect of each channel. Using stape’s channel flow tag, you can compare the first and last interaction traffic sources.  

Analyzing the first attribution traffic source is essential because it helps understand how customers heard about your site and what impact each traffic source has on brand awareness. 

Add first/last interaction source and channel flow to the CRM

Some popular CRMs like WooCommerce have plugins that help to add first/last click interactions to every order. With stape’s channel flow tag, you can add first, last, and middle attribution source/medium to the CRM. It can be a critical feature for a higher value product where you want to know each step of users’ interaction with the site before they purchase. 

How to set up the Channel Flow tag?

    2. Send data to the server GTM container. We have blog posts that describe how to send data to ss GTM using Google Analytic 4 and Data Tag/Data Client.

    3. Download Channel flow tag from GitHub -> Open templates sections in the server Google Tag Manager container -> Click New. Or add using Community Template Gallery.

    4. Click three dots in the top right corner -> Click Import -> Select channel flow tag template you’ve recently downloaded from GitHub -> Click save. 

    5. Create a new tag in the server Google Tag Manager container. Tag type should be the Channel flow tag. Make required configuration. You can modify URLs, referrals, add organic sources and set a cookie lifetime. 

    6. Add a trigger to this tag. I will trigger the Channel Flow tag on every request claimed by Google Analytics 4 client.

set up channel flow tag server google tag manager container


Channel Flow tag is an easy way to see what traffic sources drove user interactions and influenced their decisions. If you work with affiliate partners, it could help assign different commissions based on where in the journey someone has reached during your marketing campaigns or partnerships.

Channel flow tag provides insight into how users interact with your site, how they get familiar with the brand, research it, and finally, what makes them buy your product. 

This info can help to better market your products by identifying user's interaction with the site at different points along the acquisition process.

Host your GTM server at Stape