简体   繁体   中英

Double-Counting Custom Metrics in Google Tag Manager/Universal Analytics

I manage analytics for a hotel/resort site that contains 8 distinct properties, all on a single domain where each property has its own subdomain. There's a splash page at www.example.com which links to all the other properties, and the properties are located on property1.example.com, for example. I should also mention that we're using Universal Analytics nestled cozily within a Google Tag Manager container.

The problem is that for certain transactions the custom metrics are all being multiplied. 95% of purchases are for a single-room, but what's being reported in GA does not match our back-end data. Please note how the Adults metrics are all even numbers:

指标重复计算或更多

To further complicate the issue, I am using a custom HTML script which dynamically sets the corresponding property ID using a Macro:

<script>
if({{hostname}} == "property1.example.com"){
dataLayer.push({'ua': '2', 'event': 'INIT'});
}
else if({{hostname}} == "property1-ssl.example.com"){
dataLayer.push({'ua': '2', 'event': 'INIT'});
}
else if({{hostname}} == "property2.example.com"){
dataLayer.push({'ua': '3', 'event': 'INIT'});
}
else if({{hostname}} == "property2-ssl.example.com"){
dataLayer.push({'ua': '3', 'event': 'INIT'});
}
...(etc.)
</script>

The rollup account is UA-XXXXXX-1, property1 is UA-XXXXXX-2, property2 is UA-XXXXXX-3, and so forth. The rollup property is contained within a separate tag than the individual properties because it needs to fire in tandem with the property-level tag; it fires on all pages.

We're using the dataLayer to define 5 custom metrics and 6 custom dimensions. These variable pairs are first set using natural language (ie Check-In Date), then converted to their corresponding metric or dimension (ie dimension1) using a custom HTML tag.

Here is an example of some source code:

<script>
dataLayer = [{
'transactionId': '1330068',
'transactionAffiliation': 'Property1',
'transactionTotal': '3213',
'transactionTax': '931.77',
'transactionShipping': '0',
'transactionProducts': [{
'sku': '1815',
'name': 'Terrace Junior Suite',
'category': 'Example Resort Property1 - Beach Front',
'price': '3213',
'quantity': '1'
}
,{
'sku': '2256',
'name': 'Welcome Tequila Amenity',
'category': 'Example Resort Property1',
'price': '0',
'quantity': '1'
}
,{
'sku': '2257',
'name': 'Daily Fresh Fruit',
'category': 'Example Resort Property1',
'price': '0',
'quantity': '1'
}
,{
'sku': '2611',
'name': 'Complimentary In-Room Espresso and Tea Service',
'category': 'Example Resort Property1',
'price': '0',
'quantity': '1'
}],
'Room Nights': '3',
'Rooms': '1',
'Adults': '2',
'Children': '0',
'Check-In': '10/29/2013',
'Check-Out': '11/01/2013',
'Country of Origin': 'US',
'State of Origin': 'IL',
'Promo Code': '',
'Night Booking': 'yes',
'Timestamp': '60733'
}];
</script>

Here is the script I have which maps the natural language definitions to the GA-friendly index:

<script>
ga('set', {
  'dimension1': '{{Check-In}}',
  'dimension2': '{{Check-Out}}',
  'dimension3': '{{Country of Origin}}',
  'dimension4': '{{State of Origin}}',
  'dimension5': '{{Promo Code}}',
  'dimension6': '{{Night Booking}}',
  'metric1': '{{Room Nights}}',
  'metric2': '{{Rooms}}',
  'metric3': '{{Adults}}',
  'metric4': '{{Children}}',
  'metric5': '{{Timestamp}}'
});
</script>

And finally, I have a Universal Analytics pageview tag to fire off these custom metrics & dimensions. The rules for this tag are: is the confirmation URL, and event = INIT. 推动指标和维度

I could provide more details if needed, but I fear I may have lost most of you already. I think the problem relates to my custom tags, or with how the custom metrics & dimsensions are being pushed to the GA server. Thanks so much for the help!

calling ga('set', {your dimensions here}) should tell universal analytics to send the data in on every hit for the life of that tracker object (ie until a new page is loaded). So, if you've got a pageview and a transaction sent on the same page voila - double the metrics.

A quick way to check if this is the problem would be to create a custom report of transactions and see if any of your custom dimensions / metrics are associated with that hit.

Great breakdown of the scenario. It took a few minutes, but I think I'm able to wrap my head around this.

I think the issue, and it's along the lines of what you think, is ga set (this):

<script>
ga('set', {
  'dimension1': '{{Check-In}}',
  'dimension2': '{{Check-Out}}',
  'dimension3': '{{Country of Origin}}',
  'dimension4': '{{State of Origin}}',
  'dimension5': '{{Promo Code}}',
  'dimension6': '{{Night Booking}}',
  'metric1': '{{Room Nights}}',
  'metric2': '{{Rooms}}',
  'metric3': '{{Adults}}',
  'metric4': '{{Children}}',
  'metric5': '{{Timestamp}}'
});
</script>

You are setting all of your dimensions/metrics here, but you are also setting them within the Universal Analytics (beta) tag (here):

Universal Analytics代码设置

Only one is necessary, as when you refer to the macros ie Check-In, Check-Out, etc. in the Universal Analytics tag, and set the Firing Rule to {{url}} equals confirmation. You are already passing the values of the macros in the ecommerce tracking, so GTM will be able to reference these when you send.

Only one of these is necessary, and what I would do is pass the custom dimensions/metric on the Universal Analytics (beta) Track Type = Transaction (assuming this is what you're using to pass the ecommerce info to GA) and add the custom dimension/metrics (under More Settings > Custom Dimension/Custom Metrics there.

Let me know if that makes sense. Happy to help.

Check the Google tag on the page if it is double, the values will be double counted then. You will have to takeof one of the codes. So firing rule is double fired in this case. - Bhupinder Kohli

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM