In Obama's case, they got the data through users who used the Obama Facebook app. Back in 2012, the Facebook API was pretty much an open book, coughing up whatever data you asked for. Obama's campaign also used the data it has collected right up to Election Day.

In Trump's case, they got the data indirectly through Cambridge Analytica, which had been collecting the data for various purposes. Trump's campaign used some of the data prior to the General Election campaign, but not during.

From what I can tell, Obama made extensive use of more data, and was called brilliant. Trump, meanwhile, is demonized for more limited use of less data.

//