The Mexican Fisherman's Story

Author Unknown

A boat is docked in a tiny Mexican fishing village. A tourist complimented the local fishermen on the quality of their fish and asked how long it took to catch them.

"Not very long." they answered in unison.

"Why didn't you stay out longer and catch more?"

The fishermen explained that their small catches were sufficient to meet their needs and those of their families.

"But what do you do with the rest of your time?"

"We sleep late, fish a little, play with our children, and take siestas with our wives.  In the evenings, we go into the village to see our friends, have a few drinks, play the guitar, and sing a few songs. We have a full life."

The tourist interrupted, "I have an MBA from Harvard and I can help you! You should start by fishing longer every day. You can then sell the extra fish you catch. With the extra revenue, you can buy a bigger boat."

"And after that?"

"With the extra money the larger boat will bring, you can buy a second one and a third one and so on until you have an entire fleet of trawlers. Instead of selling your fish to a middle man, you can then negotiate directly with the processing plants and maybe even open your own plant. You can then leave this little village and move to  Mexico City , Los Angeles , or even  New York City !  From there you can direct your huge new enterprise."

"How long would that take?"

"Twenty, perhaps twenty-five years." replied the tourist.

"And after that?"

"Afterwards?  Well my friend, that's when it gets really interesting," answered the tourist, laughing.  "When your business gets really big, you can start buying and selling stocks and make millions!"  

"Millions?  Really?  And after that?" asked the fishermen.

"After that you'll be able to retire, live in a tiny village near the coast, sleep late, play with your children, Catch a few fish, take a siesta with your wife and spend your evenings drinking and enjoying your friends."

"With all due respect sir, but that's exactly what we are doing now.  So what's the point wasting twenty-five years?" asked the Mexicans.

And the moral of this story is:  Know where you're going in life, you may already be there!  Many times in life, money is not everything.

“Live your life before life becomes lifeless”

Get (Git) the last commit files into a zip file with folder structure

This is a handy command when working with Git.

git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD~1 HEAD | xargs tar -rf /d/temp/changes.tar

It basically takes all the changes from your last commit including the folder structure.

See more info on this SO Question.

Excluding Internal Traffic in Google Tag Manager

You've got your Google Tag Manager (GTM) up and running. Now you need to exclude internal traffic from Google Analytics. This post goes through the process of how traffic exclusion could be done on GTM.
An article on LunaMetrics ( describes how the exclusion could be done on the old version of GTM. It was a good starting point for me though.

So what traffic do you want to exclude?

  • If you have a static IP address, you could exclude the traffic by checking the IP address as described in the LunaMetrics article
    • But with the use of various devices for testing and internal users accessing the website from various locations (homes, coffee shops, via mobile networks), keeping track of those IP addresses become a nightmare
  • Cookie based exclusion
    • A cookie could be created by asking users to visit a particular hidden page (  or sending a query string parameter on any URL (
  • User agent exclusion
    • If it's a large corporate entity with managed software, the user agent string of browsers could be changed to include a specific string to identify internal traffic
  • Host name exclusion
    • In development, host names such as or localhost are used. Even IP addresses (such as are used to access development websites.

In this post, I'm using a cookie based approach to exclude traffic. But the code examples given below also help in excluding traffic to particular host names. It can be extended further to exclude traffic from certain IP addresses and particular User agent strings.

Let's get to implementing the GTM exclusions.

Code on the Client Website

According to the Tag Manager instructions, the GTM Tag should be placed just after the opening tag to work perfectly.
The code below is an example of how this is implemented in an MVC application.

I've created a partial view "GTM.cshtml" which includes the following code:

The GTM.cshtml is rendered in the base layout using @{ Html.RenderPartial("GTM"); } just below the opening body tag. In the above code I've added a dataLayer variable to assist with excluding any internal traffic. The helper function (in HelperFunctions.cshtml) returns either true or false depending on certain conditions I have set.

In the function TrackThisPage(), I have checked if the current request is sent to an URL ending with ignore or if the host name contains ".local" or if a cookie is set with ignorePageViews variable. It also checks if ignoreGTM parameter is present and if it's true or false in order to determine if this page is to be tracked.

The function could be extended to include other checks such as IP subnets which are stored as an application configuration value.

I've also got a page localhost/ignore which creates a cookie whenever a user visits it. It's important here that internal staff are asked to visit this page first before browsing the site from any device. This is a one time step which needs to be done the first time when using a new browser instance or whenever the browsing history has been cleared.

The following code shows a simple implementation where a cookie is set for a period of 10 years.

Whenever any page on the website is requested the following HTML will be returned if the page is not to be tracked.
If the page is to be tracked, the following HTML will be returned. Note the difference in the fourth line of code.

Code implementation on the client website is as simple as that.

Google Tag Manager Setup

The next step in the process is making sure that that the Google Analytics tag does not fire when the dataLayer variable "trackThisPage" is false.
In order to do this headover to the GTM dashboard at

First off a new variable needs to be created. This can done by following the steps below:

  1. Go to the particular container tracking your website and select Variables from the left hand side menu
  2. Under the User Defined Variables section click on New
  3. Change the following values as given in the screen grab below
    • Variable Name: Track this page
    • Choose Type: Data Layer Variable
    • Data Layer Variable Name: trackThisPage
    • Data Layer Version: Version 2 (make no changes)
  4. Save the variable

Creating a new variable

Once the variable is created, it needs to be associated with a Trigger to work.

  1. Select Triggers from the left hand side menu
  2. Click on New
  3. Change the following values as given in the screen grab below
    • Trigger Name: Don't track internal
    • Choose Event: Page View
    • Trigger Type: Page View
    • Fire On: Some Page Views
      • Conditions: Track this page equals false
  4. Save Trigger

Trigger not to track internal
Once the trigger is created, it should be associated with a new or existing tag. The instructions below are for creating a new tag.

  1. Select Tags from the left hand side menu
  2. Click on New
  3. Change the following values as given in the screen grab below
    • Tag Name: External Only Traffic
    • Choose Product: Google Analytics
    • Choose a Tag Type: Universal Analytics
    • Configure Tag:
      • Tracking ID: Enter your unique tracking ID here
      • Track Type: Pageview
    • Fire On: All Pages
      • Add an exclusion: Choose "Don't track internal"
  4. Save the Tag

External only traffic Tag

Test exclusions

Test your implementation by either sending "?ignoreGTM=false" or "?ignoreGTM=true" as a query string parameter to your pages.
When "?ignoreGTM=true", the Google Analytics tag should not fire. When "?ignoreGTM=false", the Analytics tag should fire and record your page view.

You can easily verify this by using the Tag Assistant (by Google) extension in Chrome. The Tag Manager preview & debug mode will also allow you to verify if this works as intended before your container is pushed live.

That's it for this post. Let me know how you go about implementing exclusions on your client websites.