React-native-branch-deep-linking-attribution: Can't log purchase events with 2.2.0

Created on 14 Dec 2017  路  20Comments  路  Source: BranchMetrics/react-native-branch-deep-linking-attribution

I have tried to log purchase events with version 2.2.0 a few different ways with no success. Here are the ways I have tried to log this event:

const purchaseEvent = new BranchEvent(BranchEvent.Purchase);
purchaseEvent.transactionID = orderNumber.toString();
purchaseEvent.revenue = parseFloat(grandTotal, 10);
purchaseEvent.logEvent();

and

// I've also tried passing an empty array instead of null for the second argument
new BranchEvent(BranchEvent.Purchase, null, {
    transactionID: orderNumber.toString(),
    revenue: parseFloat(grandTotal, 10),
}).logEvent();

Neither of these logging methods are getting the purchase event to the web dashboard (https://dashboard.branch.io/liveview/commerce). I have debugged through it a bit and it is definitely calling into the native code (I am testing on iOS right now).

I am assuming that I don't _need_ to pass a branch universal object to this method but I couldn't find anywhere in the documentation that says if that is the case one way or another.

Am I calling the new method correctly? I am able to generate a quick link with the SDK so I assume that I've got it all installed correctly.

All 20 comments

@jasonmerino That looks right. Let me review.

For a little more follow up information. It seems I am unable to log other BranchEvents as well. I have tried BranchEvent.Search and BranchEvent.AddToCart this morning with the same results of not being able to see them in the web dashboard.

I'm having a bit of trouble getting into the right account in the Branch dashboard right now. I can see the fields being populated and transmitted without errors. A couple of points:

  1. Fields representing prices (revenue, shipping, tax) are actually converted to strings before being sent to the native layer, for a certain reason. So there's no need for parseFloat. You can pass a string or a number for those fields.

  2. I suspect you have to provide the currency field as well as revenue or use a BUO with .contentMetadata.currency. For example:

const purchaseEvent = new BranchEvent(BranchEvent.Purchase);
purchaseEvent.transactionID = orderNumber.toString();
purchaseEvent.revenue = grandTotal;
purchaseEvent.currency = 'USD'
purchaseEvent.logEvent();
const buo = await branch.createBranchUniversalObject('xyz', {
  // ...
  contentMetadata: {
    currency: 'USD'
  }
})
buo.logEvent(BranchEvent.Purchase, {
  transactionID: orderNumber.toString(),
  revenue: grandTotal
})
  1. You'll find PURCHASE events on the Commerce tab under Liveview & Export. I'm not sure where all the other events end up.

I'll investigate more, but maybe that helps for now.

@jasonmerino I can confirm what you see, at least. I can't seem to get events into the Dashboard, even using the iOS TestBed app, with a live or test environment. I also see some other odd behavior in the Dashboard. I don't know if it's a general Dashboard issue. I'll keep pursuing it and let you know what I find.

In the process, I found issues with a couple of field mappings. I'll have a patch out later today. I think everything's generally working in this SDK. I can definitely see the API calls going out and receiving 200s.

@jasonmerino This appears to be a backend/dashboard issue and right now there may be a delay of hours before you see events.

You can log a purchase event without a BUO.

I have one more field mapping to fix and I'll do a new release. Hopefully the events will start showing up in the dashboard soon.

Thanks for looking into this @jdee. Is there an estimated time when those dashboard issues are probably going to be resolved? Or any issue elsewhere I can set myself as a watcher on? Also, is the delay on the events coming through on the dashboard going to be a consistent thing moving forward or is this just for the time being while the dashboard issue gets resolved?

I'm not aware of any public repo or bug tracker for the dashboard. https://status.branch.io shows all green. Your best bet is probably to contact support. I'm sure they'll be happy to keep you up to date. If I learn that things have changed, I can post an update here.

@jasonmerino jumping in here -- where are you expecting to see these events? Unfortunately our existing Liveview does not include BranchEvent. You can see these on the Source Analytics page if you hover over the column selector and choose "PURCHASE" or "ADD_TO_CART".

Can you try doing that and let me know if you see events? I believe I see purchases for your test app.

@jdee good news, the delay on these events showing up in Source Analytics should be under 5 minutes the vast majority of the time. We're focused on further speeding up these pipelines in Q1 2018.

@derrickstaten I was looking at the wrong page it seems. The revenue is showing up now, but it seems like the purchase column is out of sync with the revenue column. Right now it is showing me one purchase for a total revenue from my last two test purchases. Is there any way this is just a timing thing and the purchase count will catch up to the revenue count?

Hey @jasonmerino, I think I may know what's happening here. We display "unique" numbers on this page, so if you complete the same action over and over for the same user, the number will not increment.

We have a temporary workaround where you can see non-unique numbers by appending ?unique=false to the URL. So the full URL would be https://dashboard.branch.io/sources?unique=false. Note that this screen only shows purchases attributed back to Branch link clicks

The reason that revenue incremented (aka showed the results of both events) is that we do not calculate "unique revenue". We only have total revenue.

Let me know if this helps, and you're able to see purchases incrementing with ?unique=false.

@derrickstaten that unique=false in the query string shows both my purchases. Thanks for the follow up. So just to clarify, purchase events will only be tracked if the user has come into the app from a branch link?

@jasonmerino we track them, but we only show attributed purchases on our Source Analytics page. However, you can still export all purchases, or set up a webhook to get all purchases. In the future we may provide more analytics here beyond just attributed purchases :) If you have ideas, let us know!

@derrickstaten great. Thanks for the information!

No problem. Thanks to @jdee as well. If you have feedback re: purchase event tracking in the future, shoot it over to [email protected] and include a link to this conversation. Best of luck!

@derrickstaten I have one more question. How do I verify that the transaction ID I'm sending over is being stored correctly? I'm not seeing an option to show that on the Sources screen or in the data that I can export from that screen. Am I looking in the correct place for this?

@derrickstaten Thanks for all the help with this issue!

@jasonmerino There will be another release out soon with native SDK updates.

Hello @jdee ,
what's the status in case of current 2.2.2 release? I just tried to track purchases using BUO as described in the docs, but don't see anything in the Dashboard.

const logPurchaseToBranch = async (productID, transactionID, productDetails, affiliation) => {
  const buo = await branch.createBranchUniversalObject(productID, {
    locallyIndex: false,
    title: productID,
    contentDescription: productDetails.title,
    contentMetadata: {
      sku: productID,
      productName: productDetails.title,
      currency: productDetails.currency,
      quantity: 1,
      price: productDetails.priceValue
    }
  });

  buo.logEvent(BranchEvent.Purchase, { 
    transactionID: transactionID,
    currency: productDetails.currency,
    revenue: productDetails.priceValue,
    shipping: 0,
    tax: 0,
    affiliation: JSON.stringify(affiliation)
   });
}

Strange thing is I don't see most of the fields I fill in JavaScript when I debug Android native code:
image

Should I use BranchEvent tracking without the BUO?

@derrickstaten So now that I have purchases showing in the Sources screen, how do I see what the transaction IDs are for those purchases? Is that on the same screen? I've tried to play around with the columns that that page shows as well as export the data and I can't seem to get a hold of the transaction ID I'm sending.

@jasonmerino sorry for going silent! You can see them via exports and webhooks, both of which are available via Data Feeds on the dashboard. We're hoping to also open up a Liveview for these events in the near future, but no word on when just yet.

@derrickstaten no worries. I was able to get it figured out. Thanks for the ping back.

Was this page helpful?
0 / 5 - 0 ratings