Ravi Teja
Ravi Teja

Reputation: 3

Tag Manager to two ga properties

I have implemented Google enhanced Ecommerce Via GTM for GA Property (New), keeping the old classic analytics code in the webiste, Now I removed the old classic code and pushing the events data from the same GTM account to (old) GA property (Replicated the Tags with different GA Property, Reference url : http://www.kristaseiden.com/step-by-step-adding-a-second-ga-property-via-google-tag-manager/).

The first GA property transactions are used to track properly, But after adding another GA property the transactions and all other events are not tracking accurately. In both the accounts Transactions are dropped to 50 percent.

Could someone help me. Thanks in advance.

Upvotes: 0

Views: 429

Answers (1)

Marco
Marco

Reputation: 1172

You can create a custom JS variable:

function() {
  var newTrackingId = 'UA-XXXXXX-XX'; // Replace here
  var globalSendTaskName = '_' + newTrackingId + '_originalSendTask';
  return function(customModel) {
    window[globalSendTaskName] = window[globalSendTaskName] || customModel.get('sendHitTask');
    customModel.set('sendHitTask', function(sendModel) {
      var hitPayload = sendModel.get('hitPayload');
      var trackingId = new RegExp(sendModel.get('trackingId'), 'gi');
      window[globalSendTaskName](sendModel);
      sendModel.set('hitPayload', hitPayload.replace(trackingId, newTrackingId), true);
      window[globalSendTaskName](sendModel);
    });
  };
}

And then add this as a custom task on fields to set:

fields to set

Hope it helps!

PS: Here is a more detail post from Simo Ahava.

Upvotes: 1

Related Questions