Translation Tags

In a situation when you want to track a conversion and you already have details about the conversion in dataLayer (which may be already used by some other GTM tag) but the data structure of the conversion does not match either the Google Ecommerce or Roivenue Measurement standard, you can create a new tag that will convert the data structure or change the logic how the event is triggered. To implement this you need to:

  1. Make sure the event type already in dataLayer is not listed in event_types in roivenue.tracking.config variable. This is necessary to avoid duplicate events.

  2. create a new tag that will be triggered by the event you would like to track. The tag will read the event data, translate it into roivenue format and then push a new event of type β€œroivenue_measurement_event” into dataLayer.

  3. roivenue measurement tag is triggered by this event and capture it with its payload. The field type in the payload will work as the event type of the captured event.

Example of the tag is bellow.

The tag is being triggered by a standard conversion trigger. The tag reads the transaction details from a dataLayer variable named transactionData. Then it pushes a new event roivenue_measurement_event. This would be equivalent of calling this:

DataLayer.push({
'event' : 'conversion',
'conversionId': {{transactionData.orderId}},
'conversionType': 'purchase',
'conversionValue' : {{transactionData.orderAmount}},
'currencyCode' : {{transactionData.currency}}
});

dataLayer.push({

Here is another example of a conversion tag. Its code does not use variables but use directly contents of dataLayer. It searches for the last event of type β€œpurchase” in dataLayer and then translates and pushes a new event.

if (dataLayer) {
 for (var i = dataLayer.length - 1; i >= 0; i--) {
  
  var item = dataLayer[dataLayer.length - 1];
   
   if (item.event == 'purchase') {
    
    dataLayer.push({
     event: 'roivenue_measurement_event',
     type : 'conversion',
     conversionId: item.purchaseData.orderId,
     conversionType: 'purchase',
     conversionValue : item.purchaseData.orderAmount,
     currencyCode : item.purchaseData.currency 
    });
    
      break; 
     } 
    }
   }

The event fields needed for conversion processing are described in the Tracking Purchases and Other Conversions section of the main implementation guide.

Last updated