Going beyond E.B. or Wikipedia:
The official website of the Hagia Sophia Museum states
The first church [at the H.S. site] was constructed by Emperor Konstantios [i.e. Constantine's son] (337-361) in
360. The first church was covered with a wooden roof and expanded vertically (basilica) yet was burned down after the public riot that
took place in 404 as a result of the disagreements between Emperor
Arkadios’ (395-408) wife empress Eudoksia and Istanbul’s patriarch
Ioannes Chrysostomos, who was exiled. [...] No remains have been
recovered from the first church; however, the bricks found in the
museum storage branded ‘Megale Ekklesia’ are predicted to belong to
the first construction.
The website Hagia Sophia says
Known as the “Great Church” or “Magna Ecclesia” in Latin, the first
church was built at the same location where there had been a pagan
temple before [emphasis mine]. It was Constantius II who inaugurated Hagia Sophia on
15 February 360. From the chronicles of Socrates of Constantinople, we
know that the church was built by the orders of Constantine the Great.
Prokopius' book Buildings of Justinian, a translation of which was kindly linked to by @user2448131 gives a detailed description of the Hagia Sophia, its construction, and its beginnings post Nika revolt, but does not make any mention of pagan "foundations".
As for other historical source, there seems to be a distinct dearth when searching on that topic: there are many sites or excerpts with circular quoting referring to the pagan temple. This one stating
Some say that the site was first a pagan temple in honor of Apollo and
Which is one of the few that actually identifies the deities. As a number of other sources state Greek temple, we'll have to presume that would have been Aphrodite?
Here is a most intriguing abstract about the construction of the Hagia Sophia. It was actually designed by a pagan! Sadly the site requires registration and acedemic credentials.
A figure overlooked in scholarship on Hagia Sophia is Phokas, the
praetorian prefect of 532 under whom construction of the church began.
He was a pagan who eventually took his own life in one of Justinian’s
purges. His initial supervision of the construction of Hagia Sophia is
attested by Ioannes Lydos, himself a pagan intellectual, who praised
Phokas in superlative terms, despite Phokas’ infamous death.
Consideration of all the evidence for an architect of Hagia Sophia,
Anthemios of Tralleis, beyond the literary sources usually cited,
strongly suggests that he belonged to the pagan wing of the school of
Ammonios of Alexandria, as did the architect Isidoros of Miletos.
Material presented here explains how the last pagans of New Rome
contributed to the making of Hagia Sophia and suggests how they may
have interpreted the monument on their own terms.
On the spur of the moment, I contacted, going first via Prof. Mary Beard, her husband Prof. Robin Cormack, specialist in Byzantinistic or, as Wikipedia states, he is a British classicist and art historian, specialising in Byzantine art. He was Professor in the History of Art, Courtauld Institute of Art, University of London, 1991–2004. Despite traveling in Turkey as I write this, he was kind enough to respond he writes:
Just a short answer as we are in Turkey just now. Archaeologically
there is no clear indication, as the Constantinian church underneath
the present church has not been excavated. In the course of time all
sorts of mythic stories about the city and its origins developed.
There is a really good book about this - Gilbert Dagron,
Constantinople imaginaire . He collects all the stories and assesses
The title of the book sounds French, so I'd either have to brush up a lot on my rudimentary knowledge or some other kind soul, fluent in French, can provide information from that book.