I often hear about how positions would be bombarded for days or weeks and people always somehow survived. Were there specific methods that they would use for surviving barrages like this? Was it kind of just based off of luck?
Prior to the advent of the VT proximity fuze in WW2 artillery had severe limits to its effectiveness.
Here's the problem. An artillery shell comes in from the enemy, it hits the ground near you, its contact fuse causes it to begin to explode right when it hits the ground, it excavates a crater with its blast and directs the blast and shrapnel out of the crater at an upward angle. If the shell hits you directly: you are dead, if it lands right next to you: you are dead, but what if it just lands sort of nearby? If it hits a few meters away and you are far enough away that you won't die from the direct overpressure blast effects then what you have to worry about is the shrapnel, which can travel for many meters. But remember, the shell blew up in a crater, the shrapnel is going at an upward angle, arcing through the air above you. If a bunch of people are standing around in the open unprotected then artillery can still be very deadly since they can be hit by flying shrapnel a fair distance away from the impact.
What if people take some basic precautions to limit their vulnerability to shrapnel? What if they keep low to the ground by crawling or laying in a fox hole? What if they dig trenches and build bunkers? What if they wear helmets so that lower speed falling shrapnel and debris (the mostly likely stuff to hit someone who is a distance away from an artillery blast) has a lower chance of killing them? Well, then a lot more artillery strikes are survivable. If you happen to be standing in a trench when a shell explodes then you are dead. If a shell hits in your fox hole then you are dead. Otherwise, a lot of otherwise fairly close impacts will be survivable as the shrapnel will either go above you or rain down on you after it has slowed down a lot and your helmet will give you some protection.
Artillery in WWI could be pretty accurate, but not down to a single meter, it took raining a lot of shells onto an area to get a significant number of hits on trenches and fox holes. Even so, an enormous quantity of shells were used, so artillery was far and away the leading cause of battle deaths in most theaters of WWI, despite many soldiers surviving many artillery barrages.
The VT fuse invented by the Allies during WW2 dramatically changed the effectiveness of artillery. Artillery is more effective if it detonates in the air. Because the blast isn't directed away from the ground by the impact crater the blast effects encompass a larger area. Also, instead of the shrapnel flying upwards and mostly away from the targets (except the one directly at the location of impact) the shrapnel is directed downwards, and covers a substantially larger area. If you can achieve an artillery detonation in the air at the most effective height then even shells that are only near a trench, fox hole, or crawling troops will still be able to kill. A larger percentage of shells will cause damage, injuries, or fatalities, which will increase the amount of damage done per artillery barrage.
Achieving this effect is tricky, though, in principle you could set timers in the shells to achieve an air burst, but in practice this was not very effective in WWI, a shell will fall through the height of a building in a mere hundredth of a second, it would be impractical to precisely calculate and adjust for the exact travel time of a shell for every single square meter of target area, aside from the vaguaries of different speeds caused by slight differences in gunpowder volume, burn rate, etc. The VT proximity fuze, however, uses a very simplified and compact RADAR set to detonate at a pre-defined stand-off distance, but such technology didn't exist during WWI.