Forums / All Other Contributions/Addons / GA-4 Analytics [Support Thread]

GA-4 Analytics [Support Thread]

Started by lat9 on 17 Mar 2023, 1:05 PM · Views: 300,580

Results 1 to 20 of 61
17 Mar 2023, 1:05 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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.

19 Mar 2023, 10:48 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

Re: GA-4 Analytics [Support Thread]

Small problem on account history info page; issue created in Github wi/log.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

19 Mar 2023, 10:53 AM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

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

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

19 Mar 2023, 1:03 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: GA-4 Analytics [Support Thread]

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.

29 Mar 2023, 4:49 PM
#5
borek avatar

borek

New Zenner

Join Date:
Jul 2007
Posts:
9
Plugin Contributions:
0

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

29 Mar 2023, 5:19 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

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.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

29 Mar 2023, 7:42 PM
#7
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: GA-4 Analytics [Support Thread]

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.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

29 Mar 2023, 9:38 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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

$autoLoadConfig[90][] = [
    'autoType' => 'class',
    'loadFile' => 'observers/class.ga4_analytics.php'
];
$autoLoadConfig[90][] = [
    'autoType' => 'classInstantiate',
    'className' => 'ga4_analytics',
    'objectName' => 'ga4_analytics'
];

to read

$autoLoadConfig[[B]120[/B]][] = [
    'autoType' => 'class',
    'loadFile' => 'observers/class.ga4_analytics.php'
];
$autoLoadConfig[[B]120[/B]][] = [
    'autoType' => 'classInstantiate',
    'className' => 'ga4_analytics',
    'objectName' => 'ga4_analytics'
];
30 Mar 2023, 10:12 AM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

Re: GA-4 Analytics [Support Thread]

Nicely done @carlwhat!

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

31 Mar 2023, 9:59 AM
#10
borek avatar

borek

New Zenner

Join Date:
Jul 2007
Posts:
9
Plugin Contributions:
0

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

15 Apr 2023, 1:20 PM
#11
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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.

23 May 2023, 5:37 PM
#12
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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.

29 May 2023, 5:36 PM
#13
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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.

23 Jun 2023, 5:40 PM
#14
techiant avatar

techiant

New Zenner

Join Date:
Oct 2008
Posts:
82
Plugin Contributions:
0

Re: GA-4 Analytics [Support Thread]

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?

**Case Badges** by Techiant

23 Jun 2023, 5:57 PM
#15
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: GA-4 Analytics [Support Thread]

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.

23 Jun 2023, 6:00 PM
#16
techiant avatar

techiant

New Zenner

Join Date:
Oct 2008
Posts:
82
Plugin Contributions:
0

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?

**Case Badges** by Techiant

23 Jun 2023, 10:32 PM
#17
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,735
Plugin Contributions:
56

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/

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

25 Jun 2023, 1:02 AM
#18
gordotheflash avatar

gordotheflash

New Zenner

Join Date:
Jun 2023
Location:
Melbourne
Posts:
2
Plugin Contributions:
0

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?

25 Jun 2023, 1:23 AM
#19
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

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.

25 Jun 2023, 2:06 AM
#20
gordotheflash avatar

gordotheflash

New Zenner

Join Date:
Jun 2023
Location:
Melbourne
Posts:
2
Plugin Contributions:
0

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?