-
GA-4 Analytics [Support Thread]
Re-creating the support thread, since the original one "went missing".
The GA-4 Analytics plugin (available at https://www.zen-cart.com/downloads.php?do=file&id=2368) can be used on Zen Cart sites using 1.5.6b through 1.5.8 without issue. For 1.5.6b installations (or non-standard/older templates), be sure to read the readme since there are a couple of notifications that must be added to template files for the GA-4 Analytics' observer class to do its thing.
Other than that, no core file overwrites, just a couple of configuration settings in your admin.
-
Re: GA-4 Analytics [Support Thread]
Small problem on account history info page; issue created in Github wi/log.
-
Re: GA-4 Analytics [Support Thread]
Users of older GA plugins may wish to delete the entry under Admin > Configuration for Universal Analytics. For Simple GA it can be done by removing
admin/includes/extra_datafiles/google_analytics_database_names.php
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
swguy
Users of older GA plugins may wish to delete the entry under Admin > Configuration for Universal Analytics. For Simple GA it can be done by removing
admin/includes/extra_datafiles/google_analytics_database_names.php
Thanks, @swguy. I'll add this to the plugin's documentation.
-
Re: GA-4 Analytics [Support Thread]
Hi,
I have just yesterday installed ZC 1.5.8a and GA4.
I have found many DEBUG files in log directory.
All errors are this form:
[29-Mar-2023 16:22:41 UTC] Request URI: /index.php?main_page=product_reviews_write&products_id=11, IP address: 65.108.2.171, Language id CZK
#0 /pub/amforawa/vialux.cz/web/www/includes/classes/observers/class.ga4_analytics.php(79): zen_debug_error_handler()
#1 /pub/amforawa/vialux.cz/web/www/includes/autoload_func.php(47): ga4_analytics->__construct()
#2 /pub/amforawa/vialux.cz/web/www/includes/application_top.php(237): require('...')
#3 /pub/amforawa/vialux.cz/web/www/index.php(25): require('...')
--> PHP Warning: Undefined array key "currency" in /pub/amforawa/vialux.cz/web/www/includes/classes/observers/class.ga4_analytics.php on line 79.
on the row 79 in the ga4_analytics.php is this code:
$this->currency_decimal_places = $currencies->currencies[$_SESSION['currency']]['decimal_places'];
I find this code right, but understand what is wrong.
$_SESSION['currency'] is "CZK" and the decimal_places is ind the DB set to 2.
when I change the row 79 to this, it will works
$this->currency_decimal_places = 2;
so the problem is in the class Currencies, but I don't understav why.
can you help me?
than k you Dalibor
-
Re: GA-4 Analytics [Support Thread]
I have also seen this on one site (but not others). My workaround was to force-set that variable.
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
Borek
Hi,
I have just yesterday installed ZC 1.5.8a and GA4.
I have found many DEBUG files in log directory.
All errors are this form:
[29-Mar-2023 16:22:41 UTC] Request URI: /index.php?main_page=product_reviews_write&products_id=11, IP address: 65.108.2.171, Language id CZK
#0 /pub/amforawa/vialux.cz/web/www/includes/classes/observers/class.ga4_analytics.php(79): zen_debug_error_handler()
#1 /pub/amforawa/vialux.cz/web/www/includes/autoload_func.php(47): ga4_analytics->__construct()
#2 /pub/amforawa/vialux.cz/web/www/includes/application_top.php(237): require('...')
#3 /pub/amforawa/vialux.cz/web/www/index.php(25): require('...')
--> PHP Warning: Undefined array key "currency" in /pub/amforawa/vialux.cz/web/www/includes/classes/observers/class.ga4_analytics.php on line 79.
on the row 79 in the ga4_analytics.php is this code:
$this->currency_decimal_places = $currencies->currencies[$_SESSION['currency']]['decimal_places'];
I find this code right, but understand what is wrong.
$_SESSION['currency'] is "CZK" and the decimal_places is ind the DB set to 2.
when I change the row 79 to this, it will works
$this->currency_decimal_places = 2;
so the problem is in the class Currencies, but I don't understav why.
can you help me?
than k you Dalibor
i disagree. i think the problem is with your $_SESSION['currency'] var. the error is saying that array value is not set.
if one looks at when the currencies get set, it is at load point 120.
the ga-4 analytics code gets set at load point 90.
the ga-4 analytics needs to be loaded AFTER the currencies get loaded in order that the currency value of the SESSION array is available.
best.
-
Re: GA-4 Analytics [Support Thread]
Agreed, @carlwhat, GitHub issue opened: https://github.com/lat9/ga4-analytics/issues/13
The issue can be corrected via edit to /includes/auto_loaders/config.ga4_analytics.php, changing this section
Code:
$autoLoadConfig[90][] = [
'autoType' => 'class',
'loadFile' => 'observers/class.ga4_analytics.php'
];
$autoLoadConfig[90][] = [
'autoType' => 'classInstantiate',
'className' => 'ga4_analytics',
'objectName' => 'ga4_analytics'
];
to read
Code:
$autoLoadConfig[120][] = [
'autoType' => 'class',
'loadFile' => 'observers/class.ga4_analytics.php'
];
$autoLoadConfig[120][] = [
'autoType' => 'classInstantiate',
'className' => 'ga4_analytics',
'objectName' => 'ga4_analytics'
];
-
Re: GA-4 Analytics [Support Thread]
-
Re: GA-4 Analytics [Support Thread]
Yes, thanks.
There I don't search the problem.
I have set the index as the last one that I have in my config.core.php
have a nice day
Borek
-
Re: GA-4 Analytics [Support Thread]
GA4 Analytics v1.2.0 is now available: https://www.zen-cart.com/downloads.php?do=file&id=2368
This release contains corrections for the following GitHub issues:
#11: Correct determination of products' information pages.
#12: Don't include a view_item event for invalid products.
#13: Need to load after currencies are instantiated, corrects PHP warning.
#14: Enable analytics to use either GA4 (gtag.js) or GTM (gtm.js) reporting.
#15: Don't log a PHP Warning if the required notification is missing.
#16: Include user_id for GTM reporting and enable site-specific customizations.
#17: Correct misspelling of item_name parameter for shopping-cart based items.
-
Re: GA-4 Analytics [Support Thread]
GA-4 Analytics v1.2.1 is now available for download.
This release contains changes associated with the following GitHub issues:
#18: Correct MySQL error (products_all) when Bootstrap template is in use.
-
Re: GA-4 Analytics [Support Thread]
Sorry for the churn, but v1.2.2 is now available for download.
This version corrects unwanted PHP warnings on the featured_products page.
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
lat9
Re-creating the support thread, since the original one "went missing".
The GA-4 Analytics plugin (available at
https://www.zen-cart.com/downloads.php?do=file&id=2368) can be used on Zen Cart sites using 1.5.6b through 1.5.8 without issue. For 1.5.6b installations (or non-standard/older templates), be sure to read the readme since there are a couple of notifications that must be added to template files for the GA-4 Analytics' observer class to do its thing.
Other than that, no core file overwrites, just a couple of configuration settings in your admin.
I reviewed the readme.html but it doesn't mention older versions. How does one install this on 1.5.5f?
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
Techiant
I reviewed the readme.html but it doesn't mention older versions. How does one install this on 1.5.5f?
One doesn't! The plugin supports zc156 and later.
-
Re: GA-4 Analytics [Support Thread]
Is there another plug in that can handle GA4? Or a manual way to insert code in a header file?
-
Re: GA-4 Analytics [Support Thread]
The phrase "The plugin supports zc156 and later" means the plugin relies on internal Zen Cart code changes (often but not exclusively notifiers) that are only present in a specific release or higher.
1.5.5 is quite old and only runs on long-deprecated versions of PHP that are vulnerable to attack. You need to upgrade.
https://docs.zen-cart.com/user/upgrading/
-
Re: GA-4 Analytics [Support Thread]
I have installed the GA-4 Analytics update to Zen Cart 1.5.6c however I get an error in the log and Web site doesn't load
PHP Parse error: syntax error, unexpected '?' in /includes/classes/observers/class.ga4_analytics.php on line 309
case FILENAME_SPECIALS:
global $specials, $listing;
$products = $listing ?? $specials ?? []; <<line 309
if (empty($products)) {
break;
}
$_SESSION['ga4_analytics'][] = [
'event' => 'view_item_list',
'parameters' => [
'item_list_name' => GA4_ANALYTICS_SPECIALS,
'items' => $this->getListingItems($products),
]
];
break;
I have put the G- code in the GA4 Analytic admin field.
Any ideas?
-
Re: GA-4 Analytics [Support Thread]
You need to update the site to PHP 7.0 at a minimum. The null-coalesce operator (??) wasn't available until that PHP version.
-
Re: GA-4 Analytics [Support Thread]
Thought it might be something like that, but don't like updating PHP unless instructed.
Thank you
Updated Php version on server to 7 however I though I would see the change appear on the web site admin under the version menu?
But it still has PHP Version 5.6.40
Does it take a while to filter through?
-
Re: GA-4 Analytics [Support Thread]
@GordoTheFlash Check with your hoster. The time varies between "instantaneous" and "you must wait for a migration to another server."
Also, double check after some time has passed because you may be looking at a cached page.
-
Re: GA-4 Analytics [Support Thread]
I get that but my question is, is there a way to insert a new GA4 analytics code somewhere into the header file? I mean it's just a Javascript tracking code. Why is there a necessity for a plug in?
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
Techiant
I get that but my question is, is there a way to insert a new GA4 analytics code somewhere into the header file? I mean it's just a Javascript tracking code. Why is there a necessity for a plug in?
It depends on whether you want 'basic' tracking (i.e. page-traversal) or the 'ecommerce' events (someone added something to the cart or completed checkout).
If it's only 'basic' tracking, then just add the Google-recommended javascript to your template's html_header.php file; if you want the 'ecommerce' events, you'll need the plugin.
-
Re: GA-4 Analytics [Support Thread]
I would like to incorperate full ecommerce tracking so I was looking at this plugin, However the site already uses google tag manager and the documentation implies that it should really be one or the other and not both.
Should I be looking how to add the ecommerce tracking into tag manager or is it plausible to still install the plugin?
Thanks!
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
DannyVarley
I would like to incorperate full ecommerce tracking so I was looking at this plugin, However the site already uses google tag manager and the documentation implies that it should really be one or the other and not both.
Should I be looking how to add the ecommerce tracking into tag manager or is it plausible to still install the plugin?
Thanks!
The GA-4 Analytics plugin and be used in either GTM or GA-4 mode, depending on the type of Google Marketing ID with which you configure the plugin. If you've already got Google Tag Manager in use, then that should be removed prior to installation so that you don't get (at best) double-reporting of information or (at worst) Google "mad" at you.
I am not a Google Management Console user, but there's some magic that one must do to use a GTM- Marketing ID with GA-4; something about connecting the G- (GA-4) Marketing ID to its GTM- sibling.
-
Re: GA-4 Analytics [Support Thread]
Zen Cart 1.5.7C
Bootstrap Template 3.5.3
GA4 Analytics
GA4 Measuring ID
I'm getting slower checkout times as google Analytics is sending data to Google.. I get the spinning time tool and I can count to 10 sometimes while it's sending data to google. Is there a way to speed this up?
Website
www.gulfstatessupply.com
Thanks!
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
brian70809
Zen Cart 1.5.7C
Bootstrap Template 3.5.3
GA4 Analytics
GA4 Measuring ID
I'm getting slower checkout times as google Analytics is sending data to Google.. I get the spinning time tool and I can count to 10 sometimes while it's sending data to google. Is there a way to speed this up?
Website
www.gulfstatessupply.com
Thanks!
What's "GA4 Measuring ID"?
-
Re: GA-4 Analytics [Support Thread]
G-HCMMH1HEVY
vs the UA that is no longer supposed to be used.
-
Re: GA-4 Analytics [Support Thread]
Perhaps a "preconnect" to Google's tag manager would help. See this link for additional information.
Try adding this just after the <head> tag in the site's template's html_header.php:
Code:
<link href="https://www.googletagmanager.com" rel="preconnect" crossorigin>
FWIW, I saw no noticeable lag in the pages' display on the site.
-
Re: GA-4 Analytics [Support Thread]
I'll do what you posted.. It's only during checkout...
I use OPC with Bootstrap and the circle of time spins for about 10 seconds while someone checks out. With or without Credit Card, it's the same time.
I'll update after I put this line in.
-
Re: GA-4 Analytics [Support Thread]
It didn't fix the delay on checkout.. I tried changing to basic Template, Responsive Template, and back to Bootstrap.. used OPC and took OPC off.
I am thinking it may be a slow database issue. I'll do some homework and get back to this.
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
brian70809
It didn't fix the delay on checkout.. I tried changing to basic Template, Responsive Template, and back to Bootstrap.. used OPC and took OPC off.
I am thinking it may be a slow database issue. I'll do some homework and get back to this.
The checkout-delay is normally (both OPC and not) dependent on the number of external shipping modules (e.g. USPS, UPS, FedEx) the store uses. Each transition (for 3-page checkout) or page-refresh (for OPC) during the checkout process normally requires a poll of all enabled shipping methods.
-
Re: GA-4 Analytics [Support Thread]
v1.2.3 of GA4 Analytics is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=2368
This release contains changes associated with the following GitHub issues:
#13: Need to really load after currencies are instantiated.
#22: $_SERVER['REFERER'] might not be set on checkout payment/confirmation pages, generating logs.
#23: Page performance, push all GA4 configuration parameters via a single dataLayer.push.
-
Re: GA-4 Analytics [Support Thread]
v1.2.4 of GA4 Analytics is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=2368
This release no longer includes blank categories' names in a product's categories-list; see GitHub issue #24 for more information.
-
Re: GA-4 Analytics [Support Thread]
I have some silly questions regarding this plug-in and adwords conversion tracking.
In the readme guide of this plug-in, it is said: "Make sure that you did not add some Google tracking scripts anywhere manually in your Zen Cart files."
So I need to remove all the GA/GA4 and conversion related code from my site at first, then install the plug-in. After that, how can I track the conversion? Only rely on the data from GA4? What is the best way to track the conversion (adwords) and analyze the site (GA4) at the same time?
As a background, my site is current using the following code to track the conversion. I used to use google tag manager but it seems it cannot get the order amount. This following code can report the order amount properly.
https://docs.zen-cart.com/user/analy...rsion-tracking
-
1 Attachment(s)
Re: GA-4 Analytics [Support Thread]
That's what I did - remove all older tracking code, install GA4, then modify your Adwords Goal to use GA4 conversion data
Attachment 20710
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
ChuckPhillips
That's what I did - remove all older tracking code, install GA4, then modify your Adwords Goal to use GA4 conversion data
Attachment 20710
Thanks for sharing your idea. I will try your way then.
-
Re: GA-4 Analytics [Support Thread]
Nothing wrong with the plugin except for page speed complaining of blocking time:
/gtag/js?id=G-JQL28SP4BW(www.googletagmanager.com) Main-Thread Blocking Time : 537 ms
URL
Google Tag Manager /gtag/js?id=G-JQL28SP4BW(www.googletagmanager.com)
Total CPU Time 1,563 ms
Script Evaluation 1,276 ms
Script Parse 276 ms
Is there away to reduce it? I am getting a score of 50 for mobile on pagespeed!
Thank you
-
Re: GA-4 Analytics [Support Thread]
v2.0.0 of GA4 Analytics is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=2368
This version is released as a Zen Cart encapsulated plugin, supporting Zen Cart versions 2.1.0 and later. Thanks to @DrByte for doing the conversion to encapsulated.
-
Re: GA-4 Analytics [Support Thread]
v2.0.1 of GA4 Analytics is now available for download: https://www.zen-cart.com/downloads.php?do=file&id=2368
This version correctly update various configuration settings when upgrading from a non-encapsulated version of the plugin (#28).
-
Re: GA-4 Analytics [Support Thread]
I'm getting this on a new install of ZC 2.1
--> PHP Warning: Undefined array key "products_name" in xxxx zc_plugins/GA4/v2.0.1/catalog/includes/classes/observers/ga4AnalyticsObserver.php on line 741.
I'm going to turn it off.. I see where it's supposed to get it on line 741.. not sure why it is not getting it.
-
Re: GA-4 Analytics [Support Thread]
Same Problem with GitHub Version
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
brian70809
I'm getting this on a new install of ZC 2.1
--> PHP Warning: Undefined array key "products_name" in xxxx zc_plugins/GA4/v2.0.1/catalog/includes/classes/observers/ga4AnalyticsObserver.php on line 741.
I'm going to turn it off.. I see where it's supposed to get it on line 741.. not sure why it is not getting it.
A copy of the full log with the backtrace information would help a lot, since it's the calling path that's introduced the issue.
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
lat9
A copy of the full log with the backtrace information would help a lot, since it's the calling path that's introduced the issue.
#0 /zc_plugins/GA4/v2.0.1/catalog/includes/classes/observers/ga4AnalyticsObserver.php(741): zen_debug_error_handler()
#1 /zc_plugins/GA4/v2.0.1/catalog/includes/classes/observers/ga4AnalyticsObserver.php(238): ga4AnalyticsObserver->getItemInfo()
#2 /includes/classes/traits/NotifierManager.php(106): ga4AnalyticsObserver->update()
#3 /includes/templates/wokiee/common/tpl_main_page.php(241): base->notify()
#4 /index.php(94): require('/home/afiwwe6sf...')
--> PHP Warning: Undefined array key "products_name" in /zc_plugins/GA4/v2.0.1/catalog/includes/classes/observers/ga4AnalyticsObserver.php on line 741.
-
Re: GA-4 Analytics [Support Thread]
-
Re: GA-4 Analytics [Support Thread]
ZC 2.0.1 with GA-4 analytics version 1.2.4
Not sure if it normal behavior or a bug but when looking the page source of main page, it appears the script is being loaded 2 times. Site is at www.royal-fleur(dot)com for reference
Code:
<html dir="ltr" lang="en" prefix="og: https://ogp.me/ns# fb: https://ogp.me/ns/fb# product: https://ogp.me/ns/product#">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JQL28SP4BW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-JQL28SP4BW');
</script>
<meta charset="utf-8">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JQL28SP4BW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-JQL28SP4BW');
</script>
<link rel="preload" href="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous" as="script">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous" as="style">
Is this normal behavior? If not how can i fix it?
Would upgrading to the latest version help? I am on ZC 2.0.1 so it may not be compatible.
Thank you for your time and help
-
Re: GA-4 Analytics [Support Thread]
You'll need to find which of the Google Tag Manager IDs belongs with the current site and remove the non-current.
While it probably doesn't affect site performance, Google does not recommend having more than one gtag.
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
dbltoe
You'll need to find which of the Google Tag Manager IDs belongs with the current site and remove the non-current.
While it probably doesn't affect site performance, Google does not recommend having more than one gtag.
What Google exactly says is:
keep the number of tags [...] as lean as possible
Most browsers will not open more than four to eight HTTP requests to a single domain at a time. If you have a high number of tags on the same domain firing under the same conditions, tags will only fire within this browser limitation.
https://support.google.com/tagmanage...72488?hl=en-GB
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
dbltoe
You'll need to find which of the Google Tag Manager IDs belongs with the current site and remove the non-current.
While it probably doesn't affect site performance, Google does not recommend having more than one gtag.
Quote:
Originally Posted by
Shop Suey
What Google exactly says is:
keep the number of tags [...] as lean as possible
Most browsers will not open more than four to eight HTTP requests to a single domain at a time. If you have a high number of tags on the same domain firing under the same conditions, tags will only fire within this browser limitation.
https://support.google.com/tagmanage...72488?hl=en-GB
Thank you both for the prompt assist.
I am only using the G4-Analytics plug in.
As you can see in the page source, the gtag id is the same in both location.
Code:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JQL28SP4BW"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-JQL28SP4BW');
</script>
<meta charset="utf-8">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JQL28SP4BW"></script>
I made a test ( maybe pointless) but oddly if i change the gtag ID in the G4 Anlytic admin setting, the ID changes in both places.
I may just uninstall G4-anyltics to see if the script is still loaded. Not sure why the script would be loaded twice on the same page
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
nicksab
Thank you both for the prompt assist.
...
i love your response... although...
TIS.
Quote:
Originally Posted by
nicksab
...
Not sure why the script would be loaded twice on the same page
nick,
my 1st guess would be that potentially you have the same notifier in 2 places. why you would have that, i do not know.
i can only assume that @lat9 has tested this module, and that in a normal install, the behavior you are witnessing does not happen.
given that assumption, i would search your code base for:
NOTIFY_HTML_HEAD_TAG_START
that is the notifier that places your tag in the header. if that notifier occurs in 2 places that would explain the behavior.
your test (hardly pointless) suggests that the code where the tag gets inserted is getting hit twice.
but you definitely have some sort of issue, that i'm guessing is with your template.
in any event, that is where i would start.
best.
-
Re: GA-4 Analytics [Support Thread]
Quote:
Originally Posted by
carlwhat
i love your response... although...
TIS.
nick,
my 1st guess would be that potentially you have the same notifier in 2 places. why you would have that, i do not know.
i can only assume that @lat9 has tested this module, and that in a normal install, the behavior you are witnessing does not happen.
given that assumption, i would search your code base for:
NOTIFY_HTML_HEAD_TAG_START
that is the notifier that places your tag in the header. if that notifier occurs in 2 places that would explain the behavior.
your test (hardly pointless) suggests that the code where the tag gets inserted is getting hit twice.
but you definitely have some sort of issue, that i'm guessing is with your template.
in any event, that is where i would start.
best.
I could totally give you a hug right now.
I did a search as suggested and turns out the code got somehow duplicated:
Quote:
/includes/templates/royal_fleur/common/html_header.php
Line # 68 : $zco_notifier->notify('NOTIFY_HTML_HEAD_TAG_START', $current_page_base);
Line # 75 : $zco_notifier->notify('NOTIFY_HTML_HEAD_TAG_START', $current_page_base);
Thank you for the help as always.
-
Re: GA-4 Analytics [Support Thread]