originally presidential candidates were selected by party caucuses in congress
Congressional nominating caucus The system was introduced after George Washington had announced his retirement upon the end of his second term, when the Democratic-Republican Party, and Federalist Party began contesting elections on a partisan basis. Both parties may have held informal caucuses in 1796 to try to decide on their candidates. After the disorganized electoral voting of 1796, both parties held formal caucuses in 1800 that selected their respective presidential candidates (prior to the ratification of the 12th Amendment in 1804 each party ran two presidential candidates). The Federalists secretly held their caucus in early May, but later made their ticket of President John Adams and Charles Cotesworth Pinckney public. The Democratic-Republicans also secretly met in May, and agreed to equally support Thomas Jefferson and Aaron Burr for president. The Federalists did not hold another caucus after 1800.[1]
United States presidential nominating convention Each party sets its own rules for the participation and format of the convention. Broadly speaking, each U.S. state and territory party is apportioned a select number of voting representatives, individually known as delegates and collectively as the delegation. Each party uses its own formula for determining the size of each delegation, factoring in such considerations as population, proportion of that state's Congressional representatives or state government officials who are members of the party, and the state's voting patterns in previous presidential elections. The selection of individual delegates and their alternates, too, is governed by the bylaws of each state party, or in some cases by state law.