Sending a Custom Metric with a Pageview Tag with GTM

One would think it is easy to send a Custom Metric with a pageview yet apparently there are some mishaps which may occur due to something obscure as a timing hit. Reading through the recent article written by Yeshoua Coren describing custom and calculated metrics there was a mention of this being the issue and the idea on how to solve it though not in detail (hitCallback) – fortunately enough I have only sent Custom metrics with events which by default do not add an additional timing hit so this article is just curiosity based:).

The issue

The real issue is when you send a pageview hit which has the set custom metric if there is a subsequent timing hit the custom metric will be inflated or better say sent twice. The volume of this additional hits is very well described on Google official developer site.  So if by any chance you opt to set Fields to set field siteSpeedSampleRate like this – your reports may be polluted:


So when you send a pageview this will happen (from debug):


GTM uses set on a named tracker – tracker name is in this case gtm1453223458541 so for each subsequent hit (while it persists) for this tracker name the Custom metric will be sent again. Fortunately a subsequent event will not be affected as the name of the tracker will changed as it uses timestamp in naming convention. And now the timing hit which follows immediately after the pageview hit:


The solution (so far)

In your Pageview tag add Fields to set Field > hitCallback:


The value will be a Custom  JavaScript variable (name it as you see fit) (note that with named trackers – when you explicitly define the tracker name the situation is ‘a bit different’):

function() { 
   return function() { 
      ga(function() { 
         tracker = ga.getAll()[0].get('name');
         ga(tracker+'.set','metric2', 0);

Once you set this up the debug will show:

Running command: ga(“gtm1453224328813.set”, “metric2”, 0) which will set the value to 0 for the subsequent timing hit.


Please note that this applies to simple implementations only and should be revised especially in cases where:

  • more trackers are present
  • you use named trackers

Would be extremely happy to hear if there are any other workarounds for the issue!:)

Gmail Sponsored Promotion ads – best way to conversions

GSP ads are somewhere between the email and display advertising because the ads are created in display campaigns and show up within the Gmail platform.

More information about GSP ads can be found in this article. In second part of this post we shall show some results from one of our clients. Interesting about this case is that we started very broad targeting (interests) and then, after some time, we started to optimize.


How do GSP ads look like?

GSP ads appear in email form above received emails within the Promotions tab (Collapsed ad). After clicking on the ad, the user opens an ad that looks like an email (Expanded ad). After clicking on the call-to-action button in the expanded ad, the user is redirected to the landing page.


Collapsed ad example

collapsed ad



Expanded ad example

gsp ad veliki


GSP campaign results

We targeted customers within the GSP campaign based on different interests. For a start, we decided to advertise only one category of the client offers to see how does GSP campaign behave and how profitable it is to advertise through the GSP ads.


podaci - AW


6.91% CTR refers to the number of clicks compared to the number of impressions and do not represent the real CTR. If we calculate the ratio between the number of sessions and the number of impressions we get a 1.15% CTR which is quite high CTR considering that it is still a display campaign (average display campaign CTR is 0.20 – 0.30%).


podaci - analytics


Image above shows a significant difference between the clicks and the sessions. When someone clicks on an AdWords ad, the click is immediately recorded in the AdWords statistics. The Session is recorded only after the user was redirected to the landing page. 17,938 times users clicked on collapsed ad and 2,984 clicks on call-to-action button redirected users to the landing page.

Average cost per click was 2 RSD (0.02 EUR). Search campaign had twice as high cost per click – 4 RSD (0.03 EUR).


analytics gsp blog

We should also keep in mind display campaign’s main purpose – branding. But, the main results were this: 88 transactions, 111,977 RSD revenue and 272% ROI! Those were very good results for this type of AdWords campaigns. Do not forget – Testing different targeting can help finding the best audiences. Separate different targeting in different ad groups for easier control over the ads and cost per click.


Interesi - klikovi


Users who are interested in cooking and beauty generated most of the clicks and conversions.


Interesi - konverzije


Different targeting and more ad variations help in testing the best ad variation and users interest. GSP ads are dynamic and a large number of data is collected in short time. So, in short time you can see whether GSP ads are profitable or not. Also, some advice: to keep users attention, frequent ad change is a must.

Try GSP advertising and find out are they suitable for your business.


Snip, snip, snippet – useful and simple


Six months ago, Google introduced dynamic snippets as automated ad extension that displays the categories based on the content of landing page that match the user’s query. Because advertisers couldn’t affect what the dynamic snippet showed, Google has now introduced a new extension that gives the option of choosing specific characteristics of products or services that will be shown within the ad. This extension is called structured snippets.

example of ad with snippets

Structured snippets can help improve the CTR, and as such are indispensable in AdWords campaigns.


How to create structured snippet?

This extension can be found under the tab ‘Ad extensions’ in the drop-down menu ‘View’ as ‘Structured snippet extensions’. Structured snippet can be created on three levels – account – campaign – ad group, and the advantage of displaying has lower compared to higher level.

creation of snippet


When creating a new structured snippet, first thing you need to do is to choose one of 12 pre-defined headers:

  •   Amenities – facilities included with the product or service
  •   Brands – brands from the range of products
  •   Courses – list of courses and lectures
  •   Degree programs – programs for the acquisition of knowledge
  •   Destinations – destinations where product or service is
  •   Featured Hotels – hotels involved in a particular offer
  •   Insurance coverage – outcomes covered by insurance
  •   Neighborhoods – specific city or district in which company operates
  •   Service catalog – a list of services offered by the company
  •   Shows – plays, films, exhibitions, etc.
  •   Styles – styles of products or services
  •   Types – general header that can be used for companies whose business do not meet the headers listed above.


Choose those headers which can highlight the best features of the product or service. AdWords offers 3 examples for each header. Once you decide which header you are going to use, it is necessary to fill ‘value’ fields with categories or characteristics for which you have 25 characters. Fill at least 3 categories, while the maximum number of ‘value’ fields is 10.

value fields (categories)

When displayed with ads, minimum one category can be shown (advantage have categories in order of entry in the value field). The maximum number of categories shown depends on the number of category characters, and the size of the screen on which the ad is displayed.

Other possibilities when creating new structured snippets are choosing a mobile phone as a preferred device, setting start and end date for each snippet and making schedule for snippet displaying.


Snippets’ impact on ad performance

Structured snippets are one of the factors when calculating Ad rank. Results shown for the snippets are actually results of ads that snippet were displayed with, since they aren’t clickable.

These extensions were added to the client’s campaigns to see their influence on the ad performance. In one account ads were shown 12,939 times, along with the 8.29% CTR.

total results of the campaign

From the total number of impressions, ads with snippets were displayed  2,253 times, and in these case ads have achieved 11.41 CTR%.

results of ads that appeared with snippets

Based on the results, conclusion is that snippets have an impact on increasing the CTR of ads with which they are presented. In this case we are talking about 37.64% increase of CTR (note that the overall CTR includes CTR of ads displayed with snippets, so CTR of ads shown without snippets is lower than shown).

The reason for higher CTR on the ads with snippets probably lies in the additional information about products and services shown in snippets (also, the ad looks “bigger”) that encourage users to click on the ad to find out more.


The latest news coming from Google is that from now on two lines of structured snippets can be shown with the ad. So, best thing to do is to create a larger number of snippets 😉

2 snippets in one ad


As the structured snippets can be displayed along with other extensions make sure that you don’t repeat the same information in different extensions. Add structured snippet to your campaigns and use those characteristics (information) that are the most important for customers.

For additional explanation and instructions for creating of snippets you can watch video shown below:

90% bigger revenue thru budget & campaign optimization


It was spring of 2015 when we got a client who was actively advertising their accommodation capacities of their tourist facilities through their Adwords campaigns. After we did an audit of those campaigns, we immediately realized that there are many opportunities for improvement. We are not going to write here what exactly did we do to improve to improve the campaign, but we are going to write, among other things, how a better budget allocation  may affect the increase in revenue for over a 90%!

But first things first. AdWords account had a total of 13 active campaigns in 2014. Of these 13 campaigns, 9 of them were the classic “search” (on Google search engine results page) and 4 of them were display campaigns (on websites and portals). One of the first things we noticed during audit is that all search campaigns had a very low search impression share.

Small IS

Search campaign ads were losing their impressions – ads were not showing because of insufficient daily budget but also for targeting very low position of ad placement (search Lost IS – rank). In addition, the search campaign did not have a good structure and because of that some of the most important inquiries (according to number of conversion) were “losing” their (daily) budget. Because of that they would stop running during the mid-day.

Because of that we decided to give special attention to the allocation of the budget when planning optimization of those campaigns.

It was also interesting to note that during 2014 the campaigns had only 825 targeted words and phrases that had at least one impression. This is a very small number given the “nature” of client offer. In addition, search campaigns had only 2% CTR and average position of 4.8.

During the 2014 adwords campaigns have lead to 205 transactions and the total revenue of 1,530,429€

2014 transactions and revenue

Based on the audit of clients Adwords campaigns we came to the main factors that needed to be “repaired” to get better results:

  • optimization of the distribution of the available budget
  • campaign structure optimization
  • optimization and targeting of potentially better keywords and phrases

Based on this, we made a decision (and in light of the limited budget) to reduce investment in, or completely stop, display campaigns and all their budgets to be transferred to search campaigns. The display campaigns in 2014 accounted for some 30% of the total investment.


Results of optimization and distribution of budget


Note: we look at the entire period of 2015 although the optimized campaigns started in early April. We are doing this because it is much easier to compare the 2015 data with data from 2014.

The number of campaigns has grown to 35 – all campaigns were search campaigns. This is an increase of nearly 3 times!

During 2015 search campaign had a total 3911 targeted words and phrases that have had at least one impression (this is achieved thru proper silo structure of words, ad groups and campaigns, which is one of the main chapters in our PPC Academy) – an increase of nearly 4.5 times!

Search campaign CTR grew to 10.6% and average ad position now stands at 2.8. In other words, CTR increased by 5 times & ad position by almost double!

Position and CTR improvement

Also, there should be noted that we had about 50% less clicks on AdWords ads in 2015 (in comparison to 2014). This is because of targeting potentially better keywords and phrases.

The lower graph shows that the results have begun to appear within a few months after our takeover of AdWords account.

Transactions in 2015

Increase of transactions by 77%

Revenue in 2015

Increase of revenue by 90%

Such good results are not only attributed to the budget transfer  (from display campaigns to search campaigns) but also to the optimization of the search campaigns.

Of course, we do not say that we should always pause the display campaign, because it all depends from client to client and his  required goal (of advertising campaigns/actions). But sometimes it’s much more cost-effective, especially in the case of a very limited budget, to only activate those campaigns that give us the greatest return on investment.


Traffic management based on product performance with Google Analytics

The goal of the article is to provide the tools needed to determine which traffic acquisition channel is responsible for selling a specific product or set of products. We will do this in 2 parts. The first one deals with the direct tie between the product and the acquisition channel – please note we will be working in the realm of last non direct attribution model so it is all about the last known source. The second part deals with the situation where the product is hard to sell directly so we need to resort to more devious sales methods in specific using related products – in simple terms sell more product X by selling more product Y.

Part 1 – tie between the traffic acquisition channel and the product

Note that the following tool does not, by default, say which channel is the most effective – cost effective yet gives the information on sales volume related to source.

A prerequisite is of course a working GA property and ecommerce tracking implemented.

Believe it or not this report is available in standard reports though a bit hidden. Go to Conversions > Ecommerce > Product performance report.


Choose Pivot table for report display type.



Proceed to dimension and metric selection process:


  • Primary dimension can report on Product name, category and sku
  • Pivot by offers a selection of dimensions which you need to make sense of – depends of the questions you have:
    • choose a time based dimension if you need an answer when to sell
    • choose campaign if you want to see which campaign sold which product
    • choose basic default channel grouping (works only with standard ecommerce and not with enhanced ecommerce) or source / medium if you need a high level understanding what drives sales for a particular product (as in the current example)
  • Metrics are limited to product related scope

The table can be further filtered as appropriate – e.g. only products which generated > 10.000 product revenue.

Once the report is set you can use the Shortcut feature which will save most of the report settings and probably save you time on further reporting efforts.


Are there other ways to do this? Of course yet this is the easiest one for ad hoc analysis. Based on the report you can redefine your traffic management based on sales requirements – it gives a simple answer which channels you invested before which generated product X sales volume – this gives you the opportunity to test how a specific channel scales and can it give more.

Part 2 – Related products – Sell more X by selling more Y

So our product X is really hard to sell by itself. All our direct traffic acquisition efforts have failed (long tail campaigns) yet the product seems to sell but from completely unrelated campaigns. A solution may be that the product is more sell friendly by pushing campaigns for related products where users buy it as an additional product. So how to obtain this valuable piece of information?

Option 1 – Custom segment

Build a custom segment (the segment is user scoped) which will in return report the following – report on all products which have been bought in transactions, in defined time range, where Call of Duty: Black Ops III (our product X which causes problems) was in at least one of the transactions.


Option 2 – Related products – ecommerce feature

This is an ideal way to automate the data pull and gain some insights into correlation between products inside a transaction. It is usually used when you do not have access to a more advanced CRM / ERP which does these things – is built for these things.

Prerequisites include a working GA property, ecommerce tracking implemented and the feature enabled inside the GA view ecommerce settings.


Once turned on it allows us to fetch additional dimensions and metrics using Google Analytics Core API – more info on the subject:

For testing purposes you can use this nice addition to Google tool set – Query Explorer where you can fetch the data on the fly – basically test your query prior to any automation attempt.


After the basic setup is done you may do more tinkering in terms of filters applied – only specific product Ids or only results where the correlation score metrics is >0.8.

The end result is a table which displays the queried product Id, related product Id and the correlation score (values can be 0-1 – where values closer to 1 is what we are after – high level of correlation between the products).


This kind of report can then easily be replicated in Google Sheets using the Google Analytics extension which also allows filtering flexibility and scheduling / automation.



When you find products with high correlation score to your product X revert to part 1 of the article and see which channel is responsible for sales and test the scalability to improve both product X and product Y sales. 


How to track internal campaigns using Google Analytics

Let’s start with the basics …

What is an internal campaign

An internal campaign, from a business perspective, is any element on a site(s) which links to your content and its purpose is to speed up the purchase decision, highlight a product or category, give incentive in any part of the purchase funnel and more. A simple example would be a click on banner which is placed on our home page – – which links to a product page (also on our site(s)) –

Some examples / methods of internal campaigns:

  1. urgent – offer ends in 2 hours
  2. limited – only 5 left
  3. popular – top 5 products
  4. deal – buy 1 get one for free

The truth of the matter is internal campaigns are often used to push products with these common attributes – hard to sell, large stock, high margin and let’s not forget fill the gaps in design:)

A simple example ( – part of the homepage):


Why track internal campaigns

The obvious reason is – why not. Internal promotions often take a lot of screen real estate and this fact should not be taken lightly. Aside from that you need to invest time and money for campaign production – copy, images, … so in short you owe it to yourself to prove / test its (in)efficiency. From a marketeers perspective there are some quite useful goodies gained from tracking internal campaigns – what works and what does not:

  1. copy
  2. incentive type
  3. position
  4. colour
  5. season
  6. category
  7. price
  8. and so much more


Before we get to how to track these campaigns …

How NOT to track internal campaigns

Do not use UTM tagging to track internal campaigns. Never. Never ever.

There may be some cases where you feel tempted to use UTM taging such as a multisite environment where you own multiple properties – still, don’t.

A common error in web analytics is using features like UTM tagging for the wrong reasons resulting in bad data. If we opt to tag internal campaigns with UTM we actively affect Google Analytics traffic source attribution. Let’s see what happens if we do:

  1. A user clicks on our Google AdWords ad – Google Analytics will report on this session as coming from google / cpc
  2. Inside that session the same user clicks on our banner which has UTM tags (utm_source, utm_medium, …)
  3. This results in traffic being attributed to our banner and not Google Adwords (and will create a new session)
  4. If a user activates a type of conversion on our site standard report will attribute it to Internal campaign while the MCF part of reports will attribute Google AdWords as an assisting channel in the conversion path – a mess not easy to decipher

How TO track internal campaigns

You will probably encounter a few main methods of how to properly track this sales tool. The most popular ones are:

  1. Site search – this was nicely explained by none other than Justin Cutroni
  2. Enhanced ecommerce – this is probably the first Google Analytics feature which has a specific area designated for internal campaign (promotion) tracking this is also by far the most difficult method of tracking (as tracking internal promotions makes real sense only if you track all other EE activities on the site)
  3. Event tracking – a very flexible method of tracking almost anything on your site (I will describe some of the basic ways to do event tracking with Google Tag Manager)
  4. Custom dimensions – in addition to event tracking we can add a new layer of data to existing hits (events / pageviews) in order to better describe the actual internal promotion

As the methods 1 and 2 are described thoroughly let’s focus on event tracking and custom dimensions and we will do a hybrid of these 2.

Tracking Internal campaigns with Google Analytics Event tracking

First of all we need to decide the naming policy for our event / campaign tracking efforts. In short what will be the category, action and label values used throughout the site – note that if the naming is not consistent, time and site wise, it will be really hard to do meaningful reports. So lets revert to the basic questions – what would we like to know:

  1. Does the internal campaign help sell stuff? – we have that covered – create a segment using category / action / label and track conversion behaviour
  2. Which internal promotions are most likely to sell (and why – tricky but at least try)? – we need info here on:
    1. promotion placement (page, position)
    2. size, color, copy (think in terms of utm_content)
    3. incentive type (price, urgency, loyalty, package, any additional added value)
    4. some other attribute

As you can imagine it is not a small feat to push all these values into 3 event hit default dimensions so there is always the option to add a custom dimensions in the mix to help out (if you can spare the Custom dimensions slots!!! – note there is a limit of 20 CDs per property). An initial suggestion would be:

  • Event category = ‘internal_campaign’ (if we have a rollup property we can add the site the click happened on so it would be ‘internal_campaign_sitename’ (think utm_source))
  • Event action = ‘shoes_men_spring_2015’ (think utm_campaign)
  • Event label = ‘250*250|red|buy_now|a|2’ Ad / Banner / Campaign content (think utm_content) – size of the banner, color, CTA, variation, position (if a slider present)
  • CD1 = incentive type or some other attribute = hit scope dimension

Now that we solved what we wanted to report on let’s see how can we retrieve these values. this part will emphasize on the fact that GTM is not a one click install system and it often requires additional development work on site as the site itself is rarely built to provide info which marketeers need in an easy to consume / report form.

Trigger the Google Analytics Tag Event tag

So lets first solve the triggering part where we want to send a GA event only when someone clicks on an Internal campaign ad / link. For this case we need a way to identify the click on the internal campaign.

Here are a few basic options to solve the trigger part:

  1. use the DOM event – onmousedown, onclick – <a href=”#” onclick=”dataLayer.push({‘event’ : ‘trackEvent’}];”> – use the onclick event to push a custom event via dataLayer
  2. use GTM click / linkClick triggers which track clicks on DOM elements / links – these are GTM built in events – <a href=”#” id=”intcmp” data-gtm-data=”someImportantInfo”> – use of GTMs click / linkClick trigger in combination with auto event variables (element attributes (Click ID or element attribute auto event variable – data-gtm-data))

Trigger case 1 (DOM event)


Trigger case 2 (GTM click / linkClick)


Enable when part is optional and takes care of performance issues so you do not listen the clicks on lets say all pages but only ones that contain internal promotions. When using Auto event variables make sure the ones you will use are activated in the Variables section of GTM interface:



How to set and read the data payload for GA event tag

And now we come to the tricky part. It is not hard to send basic info to Google Analytics yet it is quite hard to come by ‘ready to consume info’ from the site. Let’s look at an example – this is not a good example of how to do it properly but an example of what you can usually expect:

<div class="slide" style="width: 980px; float: left;">
<a href="/running.html">
<img src="" alt="">

As you can see here there is almost no notion of the stuff we would really like to track – position, size, CTA, copy, color and similar. In addition to that there are no clear identifiers of the element being the internal campaign link aside from the class=”slide”.  We have two main options here:

  1. Scrape whatever we can from DOM – Click URL, image name (this gives us a really limited data set in most cases)
  2. Add some code which would better describe what the user has actually clicked (better yet we usually need developer support – preferred version)

Option 1
A very simplified way of sending the info to GTM and subsequently to Google Analytics would be to use a dataLayer custom event:

<a href="#" class="someclass" id="internalcamp" onmousedown="dataLayer.push({'event' : 'trackEvent','eventCategory': 'internal_campaign','eventAction': 'shoes_men_spring_2015','eventLabel': '250*250|red|buy_now|a|2','customDimension1':'price'});">

Option 2
An option where you have lots and lots of Custom dimensions slots available:

<a href="#" class="someclass" id="internalcamp" onmousedown="dataLayer.push({'event' : 'trackEvent','eventCategory': 'internal_campaign','eventAction':'shoes_men_spring_2015','customDimension1':'250*250','customDimension2':'red','customDimension3':'buy_now','customDimension4':'a','customDimension5':'2','customDimension6':'price'});">

Option 3
Yet another option for streamlining event information to GTM is to use HTML data attributes – I personally find this approach very useful but it is usually applicable with long term relationship clients where analytics needs are both a part of the development and marketing process (additional benefit – whatever changes in terms of class or id of the element the data-gtm- logic usually stays intact). So for example:

<a href="#" class="someclass" id="internalcamp" data-gtm-event="internal_campaign" data-gtm-action="shoes_men_spring_2015" data-gtm-label="250*250|red|buy_now|a|2">

The only thing you need to do now is to ‘catch’ the data on link click in GTM and here is how you do it:

Values needed to identify the right event and to push the final payload to event.

3 variables are needed all type of Auto Event variables where you choose Element Attribute and create all 3 data-gtm- variations.


How we trigger the Google Analytics event from GTM.


Where we send the entire payload to Google Analytics with an event.


Alternative pageview tracking with custom dimensions

Let’s assume you cannot rely on data attributes and events and your only option is adding parameters to links – it is doable and here is how to do it.

Your internal campaign directs to a page on your site: (old URL) which you should change to …*250

Follow up steps …

Read Url fragment – URL type variable where we read everything after #.


Custom dimension value extract from URL fragment (you can extract the values to one dimensions or parse the values to separate dimensions) – note that we split the entire string by ‘&’ and use the index 0 which is the 1st item and will in our case return the string ‘intcmp’:

function() {
var myTempString = {{read URL fragment}};
if(myTempString && myTempString.indexOf('intcmp')>-1){
return myTempString.split('&')[0];

An All pages for the pageview tag will suffice. If the fragment values do not exist nothing will be passed as custom dimensions values – will not be processed.

Use a Google Analytics Universal template tag with the following settings:


And this is it – happy tracking!