I ended up solving this with a few lines of code and it works really well.
Step 1.Created a file called saved_var.g with a single line in it
global z_offset = 1
Step 2. Added the following line to the end of config.g
M98 P"saved_var.g" ;Load saved z offset
Step 3. In homez.g, I replaced my G31 code with
G31 P1000 X-32 Y0 Z{global.z_offset}
Step 4. I made a Marco with the following
set global.z_offset = global.z_offset - move.axes[2].machinePosition + 0.5
echo >"saved_var.g" "global z_offset = " ^ global.z_offset
Step 5. Reboot, Home All, bring the nozzle to the correct height using my gauge. Then run the macro.
Note: I used a metal ruler that happens to be exactly 0.5mm. If you use something else, then you need to replace the 0.5 with whatever thickness gauge you use.