The consolidation process varied as the war went on. Considering the latter half of the war, it should be recalled that Allied and German attacks often threatened, sometimes overran, the gun lines. This meant that the attack on the ground caused significant disruption to the enemy artillery response. By late 1916, it was already know that consolidation of captured enemy trenches was a no-no. Engineers in the NZ Division on the Somme, for example, went forward and created new strongpoints. There were dug in a + shape and positioned well ahead of the German trenches. Even the placement of barbed wire had to be carefully considered, as the shiny new wire would stand out and mark the new positions. Strongpoints were then linked together as new trenches, and communication trenches were dug, as mentioned above.
As the war progressed, trench lines became less and less important. They were often smashed out of recognition by shellfire, which meant that defenders were in shellholes or in pillboxes, standalone shelters and blockhouses. Once captured, these would be used as command, medical and observation posts. The entrances faced the wrong way, ie towards the enemy. Extra sandbags and other precautions would be taken to protect against blast.
A crucial aspect of consolidation was mopping up. Earlier in the war (and in some of the early American attacks later in the war) German defenders in dugouts and other shelters would be bypassed. They would then emerge and machine gun the attackers from the rear. Defended villages were very important in this regard. All sides developed mopping up teams (the French called them nettoyeurs - cleaners), whose role was to go around behind the newly captured front line and bomb dugouts and the like. Hermann, in his book on Verdun, describes a nettoyeur coming down into his underground bunker and threatening to blow up the men who were huddled there. This is how he was captured.
Accurate German retaliatory artillery fire did not normally begin until at least 24 hours later. In the immediate aftermath, the Allied approach lines would be shelled because these were usually known. As mentioned, in very successful attacks then the amount of German artillery was much reduced as gun teams were moved back and re-positioned, while new gun teams were brought in to salvage the situation.
German counter-attacks were of two types. There was the immediate counter-attack that was launched by troops on the ground without significant artillery support. These were common and often ended in disaster if the initial enemy attack was successful. During Third Ypres, for example, Gegenstoss attacks were often predicted by the British and Dominion forces. Intelligence officers went forward with the attackers and immediately interrogated prisoners/read captured documents. In real time, they could work out how the Gegenstosstruppen would attack and then arrange interdiction with artillery, MG fire and LMG teams.
The second type of counter-attack (Gegenangriff) was deliberately planned, usually days after the attack. This involved specialised Stosstruppen, often including Flammenwerfer. Heavy artillery and Minenwerfer support was a prerequisite for these attacks, which were often successful (unlike Gegenstoss).