2

I am using Google Tag Manager with Google Analytics (Universal Analytics).

Here is my setup, and here is our Donation Page.

The dataLayer is created before the Google Tags as:

var dataLayer = [{
'pageCategory' : 'Donation Page',
'txnPhase' : 'Transaction Pageview',
'txnT1' : new Date()
}];

On our eCommerce page I have added this code with executes only when a transaction is committed (and it works).

//TEMP BATCH
var gaqTemp = [].concat.apply([], gaq); //Puts 3 arrays of eCome data together so I can access it easier

//DIMENSIONS
var giftID = gaqTemp[1];
var txnID = gaqTemp[11];
var txnPhase = 'Transaction Closed';

//METRICS
var giftAmount = gaqTemp[3];
var giftCount = gaqTemp[15];
var txnT2 = new Date();

//PUSH TO dataLayer
dataLayer.push({'giftID' : giftID, 'txnID' : txnID, 'txnPhase' : txnPhase, 'giftAmount' : giftAmount, 'giftCount' : giftCount, 'txnT2' : txnT2});

The result looks like this when a donation is pushed and successful: GTM Preview Mode Data Layer Messages

Here is what my Google Tag Manager (GTM) Setup looks like to track the data:

GTM Setup

And this is the Trigger: ClicksDonate_Class,

enter image description here

And lastly, here is are my setups for Custom Metrics and Dimensions in Google Analytics (GA): Custom Metrics Setup

Custom Dimensions Setup

Any of my reports with these Custom Metrics show no results (tested over several days).

I am looking for any suggestions.

Thank you, RCS

PS. Here is my previous post where I 'thought' I solved my issue... http://bit.ly/1OOhOH6

Here is another post with a similar issue.

Community
  • 1
  • 1
rorschaff
  • 167
  • 1
  • 1
  • 10
  • 1
    pageCategory is both in the Event Label and CDim, so does it show up correctly as the Label? If not, I would check the variables are properly setup as DL variables. If so, I would add more of these variables to the label and see if one is wrong/breaks it. – lossleader Dec 06 '15 at 23:38
  • Oh that is my mistake. No, I still have the same issues when the event Label is otherwise. I'll Update the image. – rorschaff Dec 07 '15 at 00:11
  • I'm not saying the label is wrong, I'm saying its current contents determines if you have one type of problem or another. – lossleader Dec 07 '15 at 00:17
  • The problem is, I don't know what the problem is. I am learning JavaScript as I go. That said, I am gettin no script errors in the console, and the data I want is being pushed into the dataLayer. But, I don't know what happends from there. My assumption is that the dataLayer variables are picked up but their references in GTM and indexed according to the assigned index, and then GA reads those indeces and retrieves their values. That's not happening unfortunately. – rorschaff Dec 07 '15 at 00:21
  • 2
    first you want to look at user behavior-> events and make sure you have these events at all, then check their label. If it wasn't "Donation Page" then the problem is clearly the DL to variable mapping. – lossleader Dec 07 '15 at 00:30
  • 1
    Please also post a screenshot of your trigger ("ClicksDonat...") – nyuen Dec 07 '15 at 00:38
  • Added the screenshot requested. The donation page is https://donate.tbvets.org/ if that helps. – rorschaff Dec 07 '15 at 00:48
  • 1
    Your trigger is set up to fire on links only, however your dataLayer shows a HTMLDivElement as clicked element. Can you try to change your trigger to a generic click instead of a link click ? Plus, install GA Debugger (Chrome extension) to see what data is actually being sent (also, use realtime view to quickly make sure event data actually arrives) – Eike Pierstorff Dec 07 '15 at 08:10
  • You are correct Eike, I have updated the trigger as you suggested. The trigger shows in real-time as an even when the Donate Button is clicked. It did not before (with the old settings). I will update this post in 24 hours, to wait for data to pass through (I hope). – rorschaff Dec 07 '15 at 20:34
  • I'm watching in GA Real-Time. I made a donation on an external IP address. I changed the tag Label to {{txnID}} and the Value to {{giftAmount}}. In GA the event pops up, as expected, with the correct 'Event Category' and 'Event Action' but the 'Event Label' reads: '(not set)'. I changed the variable to have a default value, now the Event Label reads 'not set' with no brackets. I then changed the GTM 'Event Label' to some random string, and the 'Event Label' in GA reads exactly as that random string. So the data is passing through. Just not my variable data. – rorschaff Dec 07 '15 at 21:03
  • UPDATE: All variable in image 1 produce the expected result. All variable in image 2 produce a (not set) result. Even my variable for time at T1 (txnT1) gives the correct result. I have a feeling that the dataLayer.Push is pushing variables before they populate? – rorschaff Dec 07 '15 at 21:16
  • I've tracked down the issue I believe. The dataLayer push happends on the eCommerce layer after all of the eCommerce data is sent. Then my code grabs a few pieces of data from the EC array, and only then, does it push() to the dataLayer. The trigger to retrieve the dataLayer variables is exectuted upon 'click donate button'. Therefore the trigger fires and data is passed on before the data is populated into 'giftBatch'. Thus everything is null, because that is the default state of an empty object. Null. So, I need the EC data to send, then populate giftBatch, then fire 'someTrigger'. – rorschaff Dec 07 '15 at 23:44
  • I figured this out by placing objects pairs with timestamps time stamps, and seeing where they appeared in the dataLayer. – rorschaff Dec 07 '15 at 23:46
  • 1
    @rorschaff, if you have solved this it would be nice if you would post the solution as an answer and accept (you will not get reputation for answering your own question, but the question will disappear from the "unanswered questions" tab) and then we could clear up the comments - would look much more tidy that way :-) – Eike Pierstorff Dec 08 '15 at 09:55

1 Answers1

2

Pressing the 'Donate Button' executes the following, in order: *(0) 1. Data from form pushed into eCommerce array: '_gaq'; 2. Data in eCommerce array sent to neverland (doesn't matter where); 3. 'gaqTemp' array created to concat the three '_gaq' arrays; 4. dataLayer.push() populates dataLayer with objects out of select variables from 'gaqTemp'; 5. Done.

*Somewhere between step (0) and step (1), whent he button is pressed, the GTM trigger fires (on click of button with class etc...) and the tag fires.

Everything I want to happen is happening, just not in the right order. The dataLayer is being populated at the time of 'clicks donate button', as such:

dataLayer.push({'giftAmount' : ''}); //everything is null at this point

rather than,

dataLayer.push({'giftAmount' : Some Amount});

because the variables are empty when the tag fires.

My dataLayer shows all the expected objects and values in the log, because they are pushed.

This makes my real issue, finding a way to populate the dataLayer before firing the tag to collect the dataLayer data.

rorschaff
  • 167
  • 1
  • 1
  • 10