For Forbidden City, certain tickets are held back daily to be sold to those with foreign passports. If you are not Chinese citizen proceed to the ticket counter with your passport.
for Great Wall we just booked a tour. Probably paid much more than we needed to but given limited time it worked for us. Had to go through two 'sales visits'. One of them at a tea place wasn't bad though for the experience. Other was a jade jewellery place. Didn't buy anything at both places.
Do make sure you have Alipay or WeChat payment service working before you enter China. Good idea to have e-Sim working. And helps if you have VPN installed before you enter China.