I was able to find a solution after trying multiple things. I just had to put the javascript code from google analytics between a php if
condition like this:
<?php if (cn_cookies_accepted()) { ?> <script type="text/javascript"> (function(i,s,o,g,r,a,m).{i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-#', 'auto'); ga('set', 'forceSSL', true); ga('set', 'anonymizeIp', true); ga('send', 'pageview'); </script> <?php } ?>
Related Posts:
- How to extend WordPress Bookly plugin
- php, cookies, wordpress – how to make automatic login in one one site, login and on other one
- WordPress Login Tracking Google Analytics
- How to enable button onClick functions and java script in wordpress post
- How to add custom javascript to WordPress Admin?
- How can i Toogle between 2 icons without reloading page in wordpress
- validate textfield contents in wordpress simple job board plugin
- wordpress Simple Job board plugin hide cv attachment form
- W3 Total Cache WordPress plugin disturbing my page layout
- WordPress Error: There has been a critical error on your website. Please check your site admin email inbox for instructions
- How do i give a WordPress editor access to the Site Kit by Google plugin?
- How to define custom capabilities in wordpress for custom plugin
- Why can’t import backup site WordPress? Plugin All-in-one migration
- function “add_submenu_page in wordpress connects to the home page instead of the submenu page
- PHP fopen() Error: failed to open stream: Permission denied
- Redirect after Login on WordPress
- Formidable Forms WordPress Plugin
- How to implement inline cm/inches conversion in WordPress
- JS Manga Reader with WordPress NoConflict JQuery
- Redirect old php link to wordpress link in .htaccess
- Redirect old php link to wordpress link in .htaccess
- WordPress qw.php file on root of installation
- How to change thumbnails for WordPress pages (KakaoTalk)
- google my maps ~ custom map embed into wordpress
- google my maps ~ custom map embed into wordpress
- Remove “Protected” text in title h1 of protected wordpress pages
- How to convert JPG to PNG on upload in WordPress (via add_image_size)?
- WordPress asking for my FTP credentials to install plugins
- WordPress asking for my FTP credentials to install plugins
- WordPress plugin install: Could not create directory
- What is the meaning of ‘OFFSET’ => 1 (WordPress)
- how can i get a sign in/ Register plug in like fiverr.com’s on WordPress
- WordPress makes an auto-draft as soon as I enter the page
- Using WordPress on 000webhost.com
- Add CashU payment gateway to WordPress Woocommerce
- Display only one category on home page wordpress
- WordPress custom thumbnail size
- WordPress custom thumbnail size
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Php – Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- How can I block doubleclick.net cookie from my wordpress website?
- Local WordPress installation is stripping ‘wp-admin’ from URL on WordPress admin dashboard
- How can I block doubleclick.net cookie from my wordpress website?
- Advanced Custom Fields, Yoast SEO, not updating new values in WordPress
- WordPress how to remove blocksy theme price and put my own price
- Elements wont play when combine javascript in wordpress with wp-rocket
- WordPress sort WP ULike posts in custom query?
- jetpack is in offline mode in wordpress. how to enable it and connect to our wordpress.com account
- Exclude Featured Posts in WordPress ‘Recent Posts’ Function
- WordPress: How to overlay text / widget div on top of a revolution slider
- Random Question Mark Icons In WordPress Text
- WordPress – add second logo to customizer
- Create Online template maker in wordpress website
- How can I removed Powered by WordPress link in wp.login.php without editing core WP files?
- Creating a custom rebrandly link using a wordpress shortcode
- Binance Long Short Ratio Chart In WordPress
- WordPress thumbnail cropping not working
- WordPress – Check if user is logged in
- Flaticons not showing up on WordPress
- What does arg mean in WordPress
- WordPress custom supports for custom post types
- WordPress PHP proxy/helper pages for Twitter API
- Marathi typing option in wordpress Editor
- WordPress: Loading multiple scripts with enqueue
- WordPress: Loading multiple scripts with enqueue
- Display all post meta keys and meta values of the same post ID in wordpress
- How to use wp_enqueue_style() in my WordPress theme?
- Unable to manage Google AdSense with Adspro WordPress Plugin
- Query multiple WordPress post types alternately
- About 404 during WordPress installation
- With “magic quotes” disabled, why does PHP/WordPress continue to auto-escape my POST data?
- WordPress Email Share button not opening in Outlook
- Automated Drip/ WorkFlow Form using a Plugin for WordPress site, or using a 3rd party
- “The Events Calendar” plugin by Modern Tribe in WordPress not working
- After moving WordPress, login works, but no admin access anymore
- WordPress localhost not working
- Embedding a Square Appointments script into a WordPress site – it’s rendering fullscreen in the preview pane, so I can’t edit other content. Thoughts?
- WordPress Main Menu – Hide ‘Home’ link on homepage only
- how to create a custom live search in WordPress from scratch
- Speech recognition in WordPress based on Alexa Skill
- Why am I getting 404 not found on this wordpress subdomain on my Nginx server?
- How can I access http://localhost/wordpress/wp-admin/install.php?
- How can I access http://localhost/wordpress/wp-admin/install.php?
- WP_Query(‘orderby=post_date’) not working with wordpress
- WordPress get_terms() function not display custom taxonomy categories for woocommerce
- Dash icons Not Showing properly in Menu Using WordPress
- Advanced Custom Fields, WordPress, Javascript Tabbed Content
- No paged query var being set in WordPress custom pagination
- Exclude tags from gatsby-source-wordpress-experimental
- Scalable wordpress setup
- cannot change admin password, wordpress on godaddy
- WordPress website broken in Facebook mobile browser
- WordPress Password Protected Page is not protected
- Local wordpress install only shows home page, all other pages Not Found
- How to display WordPress search results?
- Permalinks in WordPress not working
- cannot change admin password, wordpress on godaddy
- cannot change admin password, wordpress on godaddy
- WordPress – Display Random Number Between 190-250
- WordPress plugin (Q&A Lite by WPMU Dev) not working once logged out from the WordPress admin account