Google Analytics tracking code on just one page?

Having an issue where I have a client who wants his Google Analytics code on just one page. I'm using the following is_page code but in the footer.php of my child theme, but it's not appearing on the page. Is this code correct? <?php if ( is_page( 'contact' )) { echo '<script type="text/javascript">/* <![CDATA[ */ var google_conversion_id = 000000000; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "000000000"; var google_remarketing_only = false; /* …
Category: Web

how does 'init' /'parse_request' hook work for wordpress?

I wanna try to collect statistics for my wordpress website with my own plugin. the information I need is stored in $_SERVER variable. by surfing the Internet, I've two useful hooks to insert my code: parse_request 2. init Everything works fine with localhost. no data is missed, no matter it's by mobile phone or desktop, from page links or offline documents, inside apps or browser. while it's running online, something is different. After several days collecting, i've found the collected …
Category: Web

How can I add a UTM tag with PHP code to pick up the post slug dynamically in the UTM?

The thing I want to do is doable, but I don't know how to do it. Embarrassment moment coming up: I actually did this a few years ago but lost the code and can't find online how it's done. What I want to do is to add a dynamic UTM tag on a link in my header so that the UTM tag picks up the slug of the page the visitor is clicking from. Example: If the visitor is on …
Category: Web

Woocommerce + Google Analytics (Conversion Rate Not Working)

I am using WC (Version 5.7.1) & WooCommerce Google Analytics Integration (Version 1.5.3), the setup between Google Analytics and my WC website goes well so far, except the conversion rate is not calculated at all, and I guess the problem because we don't redirect the user to a thank you page where it redirects to "/checkout/order-received/order-number/?key=wc_order_key" instead. I would appreciate it if someone could help us in how we could notify Google Analytics that the checkout process is done in …
Category: Web

Disable plugin / plugin action via theme

I have installed the Google Analyticator plugin on my site. I am also using the MobilePress plugin to serve up a theme designed for non-smart-phone mobile browsers. I have set up Google Analytics for Mobile for use in this theme and would like to disable the Analyticator plugin since it includes a call to a larger js file. Does anyone know if it is possible to disable a plugin using functions.php or some other method? I believe I have located …
Category: Web

Multiple Google Analytics for Multiple pagepath

I have a landing page with one domain with multiple page path depending on my clients location, Now, I have already setup different GA tracking code and I want to track this way GA Property Code 1 = www.example.com/page/path1, www.example.com/page/path2, www.example.com/page/path3 etc GA Property Code 2 = www.example.com/page/path10, www.example.com/page/path15, www.example.com/page/path16 etc How do I go about this?
Category: Web

Google Tag Manager only load when connected to Admin

I've got this weird problem and I just don't know where to look : I've installed GTM tag on my wordpress site but it seems it's only being loaded when I'm connected as an admin. How I can tell ? In GTM, i've setup the following simple tag <script type="text/javascript"> console.log('gtm test html tag'); </script> This code is only triggered when I'm connected to wp-admin. PS : Here's other informations that I think may enter in play, but im not …
Category: Web

Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress

On the WordPress site, I have beehive pro installed, (this question is beyond the support scope) and I'm trying to get all the hyperlink's title attributes and send them to Google analytics as a custom label Google tag manager. The client has 200+ hyperlinks to PDF documents and needs to track the downloads of these files. This piece of code dynamically applies the title attribute to each link by extracting it from the filename of the PDF file: jQuery( function …
Category: Web

wp_add_inline_script not adding when script_loader_tag filtered

I'm trying to add the new GA4 code to an existing site, and there seems to be some conflict / ordering issue between script_loader_tag filters and wp_add_inline_script. My functions.php looks thusly: ... // Enqueue scripts function cwr_enqueue_scripts() { wp_enqueue_script('cwr-google-analytics', get_stylesheet_directory_uri() . '/js/ga.js', array(), '1.0.3'); wp_add_inline_script('cwr-google-analytics', "ga('create', " . "'" . CWR_GAUA_ID . "', 'auto');ga('send', 'pageview');"); wp_enqueue_script('cwr-google-gtag', "https://www.googletagmanager.com" . "/gtag/js?id=" . CWR_GA4_ID, array(), null); wp_add_inline_script('cwr-google-gtag', "window.dataLayer = " . "window.dataLayer || [];" . "function gtag(){dataLayer.push(arguments);} gtag('js'," . "new Date()); gtag('config', '" …
Category: Web

dynamic page not displaying correctly when Varnish hosting ignores query string parameters

I have a WP site with managed hosting that uses Varnish. I have a landing page that displays the appropriate images based on a couple arguments passed through the query string. So for example, depending on where the user is requesting this page from, the URL might be www.example.com/landing?v=1 or www.example.com/landing?v=2... and each of those pages would contain a different logo image that is determined by the value of v in the query string. It seems that the default behavior …
Category: Web

Google Analytics gtag code messes up woocommerce cart & login

I'm having this issue where this code provided by google analytics gtag, added with either wp_head() or wp_footer() or a GA plugin: <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-XXXXXXXXX'); </script> Messes up the cart & login. For login, this happens: users logs in, refreshes to same page with login prompt, log again and you're in after second attempt. Click on any menu and login prompt again. Do this login (third) and …
Category: Web

Google Analytics - add script to functions.php

I want to connect google analytics to my site. I don't want to do it through the MonsterInsights plug-in. I added this script to functions.php. Will it work? <?php /** * Add functions files * * @package Virtue Theme */ /** * Language setup */ function virtue_lang_setup() { load_theme_textdomain( 'virtue', get_template_directory() . '/languages' ); } add_action('wp_head', 'my_analytics', 20); function my_analytics() { ?> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-00000000-1"></script> <script> window.dataLayer = window.dataLayer || []; …
Category: Web

Tracking sales/conversions in Woocommerce using Google Analytics

I need to be able to track conversions/orders in Woocommerce and have tried every free plugin available and none have worked or seem to be able to track sales correctly. Has anyone found a free plugin that actually shows ecommerce transactions in Google Analytics or perhaps uses an alternative approach such as Google Tag Manager or Conversion code on the checkout success page.
Category: Web

How do I export categories, site stats, comments and posts from wordpress to excel

I need to export the posts, categories, the author, the page views and comments from WordPress to excel. This is because I need to analyze the performance of each author and each category based on page views and comments. I tried the WP all Export plugin but it was not compatible with the site. How can I go about achieving this. It is quite urgent and I need help
Category: Web

Google Tag Manger - no-script Code Not Found

I am having trouble getting the "GTM no-script code not found: either missing or not in " issue resolved. The GTM script is placed after the < head > tag. No issues. However, when using the Google Chrome Tag Assistant, I keep getting the "GTM no-script code not found: either missing or not in " error. Here is where I am placing the GTM noscript code in the header.php file: <body <?php body_class(); ?>> <!-- Google Tag Manager (noscript) --> …
Category: Web

When add analytics script, wordpress user login not working

When i add Google analytics script the below one https://www.googletagmanager.com/gtag/js?id=UA-XXXXXX-X″> (with actual container ID) , my user login not functioning well. I checked console, resolved warnings and all. I tried the way like integrate analytics using tag manager and that case also same problem for user login Anyone faced this issue? Please help
Category: Web

How to find and remove the tracking codes running in my wordpress site?

In one of my old websites I inserted GTM and GA tracking codes. Now when I run my website 'BathindaHelper.com' in G Chrome, its Tag extension shows 3 tags are running (2 for GTM and one for GA). But when I check my wordpress website's backend, I don't find the code inserted in the theme 'header.php' or 'footer.php'. I also deleted any plugins like 'Insert Headers & Footers' or similar. How can I find and remove those tags?
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.