I figured out why this wasn’t working.
When you cut and paste the code in, it changes the quotes from single quotes to inverted apostrophes and a similar thing with the double quotes.
I’ve got the hidden fields in my forms now, but when I read the HTML source the variables are empty (i.e. no IP address). Any ideas what I’m missing?