Disclaimer: I was brought on a few weeks ago, and do not know all of the client's decisions for prior development. I was not part of the original site development team. Admittedly I have not had any experience with handling off/on transactions, and this is where I could use your assistance.
Overview: A couple months ago, a client had an offshore developer set up Google Tag Manager. Since then, the client has been seeing a significant difference in Google Analytics metrics and internal metrics. They found that the e-commerce transactions/conversions for Paid Search and Social channels only pick up a small handful of actual transactions, and somewhere in the chain of events a majority of the transactions are not reported to the GA dashboard and are being lost in the ether.
First Glance: The client is running a Drupal 7 site with the GA script hard-coded into the theme. I found this strange since there is a module for GA available and looked to be running on the site at one point, but the module being disabled is likely due to the decision of the offshore dev and their integration of Google Tag Manager.
The code also looked shoddy. GA code was running from inside of the body tags, GTM was right alongside it (it is still currently in the body tag), and there were a lot of other questionable pieces of code. I made some updates and moved the code around where necessary, but the transactions still did not show appropriately within the Google Analytics dashboard.
Checking the GA dashboard, I found that the standard channels were system defined, and it didn't look like anything was done that could show improper results (if you have any advice on checking for modifications that may throw off results within the GA dashboard, I am open to that).
The client also has integrated with a third party shopping cart, and after noticing that cross-domain tracking on the client's site was not properly implemented, I updated the script. The third-party cart does seem to be implemented properly.
Code (current):
GA (identifiers removed, placed in head):
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-xxxxx-1', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['third-party-shopping-cart-example.com'] );
ga('send', 'pageview');
</script>
GTM (identifiers removed, placed in body):
<noscript>
<iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX"
height="0" width="0" style="display:none;visibility:hidden">
</iframe>
</noscript>
<script>(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(), event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'//www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-XXXX');
</script>
Summary: Google Tag Manager was shoddily implemented alongside Google Analytics, and e-commerce transactions for the "Paid Search" and "Social" channels are rarely reporting. If you have any thoughts or solutions for this issue, I am all ears.
Thank you for your time, I really appreciate it.