First, make sure you have verified your site in Google Webmaster tools.
Once you have created the search engine, copy the search engine ID.
Go to the site editor and click 'Insert' in the main toolbar.
In the left sidebar, from the 'Apps' category choose 'Google Search'. The app will be added to the page.
Double click on the app to open the app window, and paste your Google Search ID. You'll see a preview of the app on the left of the window. Click 'Apply' and save your changes. You can preview the app on your site by clicking 'View my site'.
Tracking your site searches in Google Analytics
It's possible to link your Google custom search box to your Google Analytics account. This will allow you to track how many searches your site receives and what terms visitors are searching for.
In Google Analytics, go to Admin and select the view you want to track searches in.
Click 'View settings'. Under 'Site search settings', turn tracking on.
Enter q, query, s, search, term into the 'Query parameter' box (see below) & save.
Lastly, follow the steps in this guide to link your search engine with your Google Analytics view (like below).
You can then view your site search data in analytics. (Go to Reporting> Behaviour> Site search).
Note: It may take a couple of hours for your site search data to display in analytics.