Upvote:0
You will clear US Customs and US Immigration at Toronto prior to arriving in the United States, in a procedure called Preclearance. You no longer need to collect your baggage for inspection but of course US Customs may inspect your bag if they wish. You do not need to go through Canadian customs. The procedure is well sign posted: follow the purple signs. When you arrive in San Francisco you have already completed immigration formalities and your flight is treated as a domestic arrival.