Jump to content

Google Analytics Problem


Recommended Posts

Since upgrading to version 4.0.0 of Google Analytics I get an error when trying to navigate to checkout in the front office. If I disable the module everything works OK.


It get the following error...
 

(1/1) ContextErrorException

Notice: Array to string conversion

in HookDisplayFooter.php line 74

at HookDisplayFooter->run()in ps_googleanalytics.php line 111

....

Line 74 in HookDisplayFooter.php is in bold below:

 

        $gaScripts = '';
        $this->module->js_state = 0;
        $gacarts = $ganalyticsDataHandler->manageData('', 'R');
        $controller_name = Tools::getValue('controller');

        if (count($gacarts) > 0 && $controller_name != 'product') {
            $this->module->filterable = 0;

            foreach ($gacarts as $gacart) {
                if (isset($gacart['quantity'])) {
                    if ($gacart['quantity'] > 0) {
                        $gaScripts .= 'MBG.addToCart(' . json_encode($gacart) . ');';
                    } elseif ($gacart['quantity'] < 0) {
                        $gacart['quantity'] = abs($gacart['quantity']);
                        $gaScripts .= 'MBG.removeFromCart(' . json_encode($gacart) . ');';
                    }
                } else {
                    $gaScripts .= $gacart;
                }
            }

            $ganalyticsDataHandler->manageData('', 'D');
        }

 

 I have no idea to fix the issue, any help or guidance would be appreciated

Thanks,

Matt

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

Bump. Experiencing same issue. Has to do something with module Google Analitics tracking. For me it happens at checkout step. In using 1.7.6.7 version with custom theme. Php version 7.2


(1/1) ContextErrorException
Notice: Array to string conversion

in HookDisplayFooter.php line 74
at HookDisplayFooter->run()
in ps_googleanalytics.php line 111
at Ps_Googleanalytics->hookDisplayFooter(array('smarty' => object(SmartyDevTemplate), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 2))
in Hook.php line 970
at HookCore::coreCallHook(object(Ps_Googleanalytics), 'hookdisplayFooter', array('smarty' => object(SmartyDevTemplate), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 2))
in Hook.php line 355
at HookCore::callHookOn(object(Ps_Googleanalytics), 'displayFooter', array('smarty' => object(SmartyDevTemplate), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 2))
in Hook.php line 907
at HookCore::exec('displayFooter', array('smarty' => object(SmartyDevTemplate), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 2), null)
in smarty.config.inc.php line 167
at smartyHook(array('h' => 'displayFooter'), object(SmartyDevTemplate))
in SmartyLazyRegister.php line 83
at SmartyLazyRegister->__call('smartyHook', array(array('h' => 'displayFooter'), object(SmartyDevTemplate)))
in 3cc5f078f09a6d6ed6265bba4a1ab6c944819596_2.file.footer.tpl.php line 115
at Block_14645850055f4ac055e15b08_80828159->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_14645850055f4ac055e15b08_80828159), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_14645850055f4ac055e15b08_80828159))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_14645850055f4ac055e15b08_80828159', 'hook_footer', 11)
in 3cc5f078f09a6d6ed6265bba4a1ab6c944819596_2.file.footer.tpl.php line 160
at Block_13563459485f4ac055e13d50_47003828->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_13563459485f4ac055e13d50_47003828), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_13563459485f4ac055e13d50_47003828))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_13563459485f4ac055e13d50_47003828', 'footer_main')
in 3cc5f078f09a6d6ed6265bba4a1ab6c944819596_2.file.footer.tpl.php line 31
at content_5f4ac055e17e17_20570834(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()
in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('file:_partials/footer.tpl', null, 'layouts/layout-left-column.tpl', 0, 31536000, array(), 0, false)
in e715f760a3d91c84f22bd29f116ceacd21baa8fa_2.file.layout-both-columns.tpl.php line 397
at Block_17959379225f4ac055760520_82426645->callBlock(object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 248
at Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_17959379225f4ac055760520_82426645), object(SmartyDevTemplate))
in smarty_internal_runtime_inheritance.php line 184
at Smarty_Internal_Runtime_Inheritance->process(object(SmartyDevTemplate), object(Block_17959379225f4ac055760520_82426645))
in smarty_internal_runtime_inheritance.php line 156
at Smarty_Internal_Runtime_Inheritance->instanceBlock(object(SmartyDevTemplate), 'Block_17959379225f4ac055760520_82426645', 'footer')
in e715f760a3d91c84f22bd29f116ceacd21baa8fa_2.file.layout-both-columns.tpl.php line 110
at content_5f4ac055766f73_50118935(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()
in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('layouts/layout-both-columns.tpl', null, 'layouts/layout-left-column.tpl', 0, 31536000, array(), 2, false, null, null)
in smarty_internal_runtime_inheritance.php line 125
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'layouts/layout-both-columns.tpl')
in f59585abba9ae60d008eabef2170d328bf83d5bc_2.file.layout-left-column.tpl.php line 33
at content_5f4ac05574faf9_53073824(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render()
in smarty_internal_template.php line 385
at Smarty_Internal_Template->_subTemplateRender('layouts/layout-left-column.tpl', null, 'layouts/layout-left-column.tpl', 0, 31536000, array(), 2, false, null, null)
in smarty_internal_runtime_inheritance.php line 125
at Smarty_Internal_Runtime_Inheritance->endChild(object(SmartyDevTemplate), 'layouts/layout-left-column.tpl')
in 286e6bda4f50276a3191690073954c4eeb3724a2_2.file.checkout.tpl.php line 35
at content_5f4ac05574b639_24525461(object(SmartyDevTemplate))
in smarty_template_resource_base.php line 123
at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))
in smarty_template_compiled.php line 114
at Smarty_Template_Compiled->render(object(SmartyDevTemplate))
in smarty_internal_template.php line 216
at Smarty_Internal_Template->render(false, 0)
in smarty_internal_templatebase.php line 232
at Smarty_Internal_TemplateBase->_execute(object(SmartyDevTemplate), null, 'layouts/layout-left-column.tpl', null, 0)
in smarty_internal_templatebase.php line 116
at Smarty_Internal_TemplateBase->fetch('checkout/checkout.tpl', null, 'layouts/layout-left-column.tpl', null, false, true, false)
in SmartyDev.php line 40
at SmartyDev->fetch('checkout/checkout.tpl', null, 'layouts/layout-left-column.tpl')
in FrontController.php line 683
at FrontControllerCore->smartyOutputContent('checkout/checkout.tpl')
in FrontController.php line 667
at FrontControllerCore->display()
in Controller.php line 312
at ControllerCore->run()
in Dispatcher.php line 515
at DispatcherCore->dispatch()
in index.php line 28

 

Edited by huhuhu7765 (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...
On 9/17/2020 at 3:22 PM, samuel-boucher said:

Hi,

We have a PR about this topic on github: https://github.com/PrestaShop/ps_googleanalytics/pull/59.

Issue fixed, merged and validated by QA today.

Thank you

Samuel

I can confirm this BUGFIX! 

Thank you samuel-boucher

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 2 months later...
  • 6 months later...

this issue still persists.

i have latest PS 1.7.8

i have PS google analytics 4.1.0

I use php7.4

and i get error:

at HookDisplayFooter->run()in ps_googleanalytics.php line 113

if i disable the module it works, enable it and site is broken

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
On 10/15/2021 at 1:33 PM, DarrenJ said:

this issue still persists.

i have latest PS 1.7.8

i have PS google analytics 4.1.0

I use php7.4

and i get error:

at HookDisplayFooter->run()in ps_googleanalytics.php line 113

if i disable the module it works, enable it and site is broken

Check this fix : https://github.com/PrestaShop/ps_googleanalytics/pull/107/files

Replace this line 90 in file /ps_googleanalytics/classes/Hook/HookDisplayFooter.php

$products = $productWrapper->wrapProductList($listing['products'], [], true);

to 

$products = $productWrapper->wrapProductList(isset($listing['products']) ? $listing['products'] : [], [], true);

 

Edited by corrigerunbug (see edit history)
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...