Does the Polearm Master bonus attack have to be used after the main attack?

Using the Polearm Master bonus attack rules:

When you take the Attack action and attack with only a glaive, halberd, quarterstaff, or spear, you can use a bonus action to make a melee attack with the opposite end of the weapon.

Does this additional attack clearly occur after the attack with the main weapon, or is there a time to use it between the attack being "declared" and resolving the main attack?

Background/motivation: I would like to attempt the following:

  1. Announce I am attacking Bandit Keith;
  2. Use the bonus action to attack with my halberd’s shaft, with a Tripping Attack maneuver;
  3. Assuming success on the attack / STR check, attack with the halberd blade at advantage;

While that appears to fit how the flow of a fight works in my head, the word take appears a bit ambiguous to me if I wish to argue from RAW. If an Action is taken does this mean it is completely resolved?