WHMCS has addon module for Google Analytic that fully automates the integration process. For information you can read here
Anyway, if you have Google Analytic Integration code and want to insert it with your WHMCS theme then you can insert that code by editing header.tpl file with your theme.
To insert integration code connect FTP/cPanel/etc and access your WHMCS files. Go to this path /whmcsdir/templates/your template/ and edit header.tpl file. Copy and paste your integration code somewhere between <head></head> tags and insert integration code with smarty tags {literal}{/literal}.
Note. whmcsdir is your WHMCS installation folder. It could be under public_html or under any subfolder.
Example:
<!-- Global site tag (gtag.js) - Google Analytics -->
{literal}
Your Google Analytic script goes here
{/literal}
<!-- End Google Analytics -->
If you want to insert tracking code on cart.php?a=complete page then do it same as above but path would be /whmcsdir/templates/orderforms/your orderform template/ and edit complete.tpl file and insert code similar as mentioned above in smarty tags {literal}{/literal}.
Note. Do not forget to use smarty tags {literal}{/literal} otherwise your website will crash and show empty page.