Who Me Too'd this topic

Who Me Too'd this topic

Bronze Contributor
Bronze Contributor

Hello,

 

Apart from modifying every tag template, is there a way to cut these lines of code on every tags ?

Like a "No Ecommerce" global option ?

Some of my collegues are very sensitive to performance issues and would like to avoid running these lines if not necessary (every little helps you know ;) ).

        // automatically fires Purchase tracking if an order ID is present
        if (u.data.order_id) {
          tracked_purchase = true;
          event_data.orderId = u.data.order_id;
          event_data.orderValue = u.data.order_subtotal;
          event_data.currency = u.data.order_currency;
          event_data = u.clearEmptyKeys(event_data);
          obApi("track","Purchase",event_data);
        }

        for (j = 0; j < u.data.event.length; j++) {
          // prevents duplicate purchase tracking, but allows explicitly set Purchase tracking in situations where an order ID may not be present
          if (u.data.event[j] === "Purchase" && !tracked_purchase) {
            tracked_purchase = true;
            event_data.orderId = u.data[u.data.event[j]].order_id || u.data.order_id;
            event_data.orderValue = u.data[u.data.event[j]].order_subtotal || u.data.order_subtotal;
            event_data.currency = u.data[u.data.event[j]].order_currency || u.data.order_currency || "USD";
          }
          event_data = u.clearEmptyKeys(u.data[u.data.event[j]]);
          if (utag.ut.isEmptyObject(u.data[u.data.event[j]])) {
            obApi("track",u.data.event[j]);
          } else {
            obApi("track",u.data.event[j],u.data[u.data.event[j]]);
          }
        }

Regards,

Guillaume

Guillaume
Who Me Too'd this topic
Public