There is no reliable or accurate way to detect if someone is browsing in an incognito/private/safe browsing mode through Javascript or CSS
It could be done before 2014 with a css hack but not now
See here for details
https://stackoverflow.com/questions/2860879/detecting-if-a-browser-is-using-private-browsing-mode
See the original question here: https://www.en.advertisercommunity.com/t5/Tracking-Goals-Ecommerce/GA-Event-Within-Incognito/m-p/592622#M5319