I don't have sources currently, but I remember in a podcast by Lars Bronsworth he mentions that during the Iconomachia, a period of about 100 years in Byzantine History where the Empire was split between those who wanted icons removed from religious practices and those in favor of them, the Venetians, outraged by the current Emperor's decree against icons, elected their own Doge to lead them. Afterwards, they still had decent relations with the Byzantines and were nominally part of the Empire, but they were pretty much independent. When the Empire was reeling, they needed the Venetians many items, either to use their navy or their money. So, they gave them some extra rights in the Byzantine ports, such as less tolls and also a part of the port of Constantinople. One such grant of rights is the Chrysovoulo, by Emperor Alexios Komnenos. However, the Crusades, among other things, strained the tensions between the Empire and the West in general. This tension came to a head when, during the reign of Andronicus Komnenos the citizens attacked the western enclave in Constantinople, killing many. So, this anger against the Empire, plus the aspirations of the Venetians for more money and goods, as well as them wanting to beat their rival, Genoa, in addition to the cunning of their current Doge, Errico Dandolo (who by the way, participated in the siege of Constantinople even though he was more than 90 years old) led to the Venetians taking part in the Fourth Crusade. In the treaty between the Crusaders, Venice essentially got most of the important ports and sources of incone Byzantium had, which was what they wanted. They also tried to install a puppet Emperor but didn't manage that.