Unfortunately I can’t offer much help as I’m no longer using gcse. I did have it working for awhile, but ended moving away from google generally and removed it quite a few discourse versions ago. What was posted above worked but I had to play quite a bit with it between infinite scroll issues and between discourse changes.
What have you tried? and what errors/issues?
A cleaner/easier option that shouldn’t need much management might be to simply include a button on the top that goes to a google hosted search page or something of your own somewhere.