Article snapshot taken from Wikipedia with creative commons attribution-sharealike license.
Give it a read and then ask your questions in the chat.
We can research this topic together.
Although Clinton won the state's presidential election, however, Clinton lost to Madison in the national presidential election, making this the third time New Hampshire voted for a losing candidate in its presidential voting history.
Results
1812 United States presidential election in New Hampshire
While commonly labeled as the Federalist candidate, Clinton technically ran as a Democratic-Republican and was not nominated by the Federalist party itself, the latter simply deciding not to field a candidate. This did not prevent endorsements from state Federalist parties (such as in Pennsylvania), but he received the endorsement from the New York state Democratic-Republicans as well
John Langdon had originally been nominated as Madison's running mate, however Langdon declined the nomination and Gerry was chosen instead.