November Happy Hour will be moved to Thursday December 5th.

Commerce Tracking

Vote:
 

Commerce 12.11.0

Hi

Does anyone know if the  CommerceTrackingAttribute can be used on Web Api controller actions ? And by default sends the User tracking data i.e Name and email of logged in user ?

Also whether using the TrackingDataFactory Create methods automatically constructs the User tracking data from the logged in user ?

Thanks

#203954
Edited, May 14, 2019 11:55
Vote:
 

Unless I missed something obvious, then no, CommerceTrackingAttribute is based on ActionFilterAttribute which is an for-MVC attribute. IIRC you just can't use it in a WebApi controller.

#203965
May 14, 2019 17:58
Vote:
 

You might be able to use the approach titled " Tracking without using the CommerceTrackingAttribute" as described here: https://world.episerver.com/documentation/developer-guides/tracking/product-tracking/ 

#203969
May 14, 2019 22:19
Vote:
 

Thanks, I thought so too, wanted to confirm. 

Had been through the Tracking without attribute approach, but from the documentation it's not obvious if the User tracking data is automatically constructed by the TrackingDataFactory or do I have to add it ?

#203970
May 14, 2019 22:47
Vote:
 

From memory it used the ASP.net Profile values as used in Commerce. So unless you are using that in your WebAPI controller it’s likely you need to populate yourself. 

Again from memory you can populate the UserData object with your custom tracking. You only need to populate the email to match with an existing profile with matching email. 

If you cannot populate UserData as part of your implementation then you can use a tracking data interceptor to populate it: https://world.episerver.com/documentation/developer-guides/tracking/tracking-api/tracking-data-interceptor/ (this is what’s used by the default implementations) 

#203971
May 14, 2019 23:25
Vote:
 

Thanks David

#203972
May 15, 2019 0:13
Vote:
 

Update on this

I can confirm that the User tracking data is automatically constructed by the TrackingDataFactory CreateTrackingData methods. It does seem to be using the ASP.NET profile values. In my case my WebAPI controller is hosted within the Commerce site so it works out

#204812
Jun 19, 2019 2:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.