Code to defer Google analytics until website user gives permission.

Job ID: 33149304

Budget: £20 – £250 GBP

Code to refer Google analytics until website user gives permission. Looking for code that can be easily implemented across Wordpress/elementor sites to ensure sites are GDPR compliant and the the analytics script does not load until user has given their permission. I would preferably not want to use a plugin.
Related categories: PHP JavaScript WordPress Google Analytics Elementor