1) Yes, the trip attempt counts for Hammer the Gap if it hits.
From the PFSRD on Combat Maneuvers (emphasis mine):
When you attempt to perform a combat maneuver, make an attack roll and add your CMB in place of your normal attack bonus. Add any bonuses you currently have on attack rolls due to spells, feats, and other effects. These bonuses must be applicable to the weapon or attack used to perform the maneuver. The DC of this maneuver is your target’s Combat Maneuver Defense. Combat maneuvers are attack rolls, so you must roll for concealment and take any other penalties that would normally apply to an attack roll.
Combat maneuvers are attack rolls. Hammer the Gap gives a bonus for each attack that hits. If the trip attempt hits, it counts for Hammer the Gap.
2) Yes, the attack of opportunity counts for Hammer the Gap if it it hits.
From the PFSRD on Hammer the Gap, (emphasis mine):
When you take a full-attack action, each consecutive hit against the same opponent deals extra damage equal to the number of previous consecutive hits you have made against that opponent this turn. This damage is multiplied on a critical hit.
Hammer the Gap counts all hits since the start of your turn. The attack of opportunity happened on your turn. Therefore it counts for Hammer the Gap.