How to know if Stoploss is Hit or Target Profit Hit with a variable

When a set exits, I like to know this. Whether Set exit happened due to Stoploss being hit or Partial Target Profit hit. I like to capture this information in a variable. Set exit due to stop. Set exit due to take profit.
Any ideas how do we realise this in the strategy ?