@@ -182,6 +182,22 @@ public function displayForm()
182182 'label ' => $ this ->l ('Disabled ' )
183183 ))
184184 ),
185+ array (
186+ 'type ' => 'switch ' ,
187+ 'label ' => $ this ->l ('Enable Cross-Domain tracking ' ),
188+ 'name ' => 'GA_CROSSDOMAIN_ENABLED ' ,
189+ 'values ' => array (
190+ array (
191+ 'id ' => 'ga_crossdomain_enabled ' ,
192+ 'value ' => 1 ,
193+ 'label ' => $ this ->l ('Enabled ' )
194+ ),
195+ array (
196+ 'id ' => 'ga_crossdomain_disabled ' ,
197+ 'value ' => 0 ,
198+ 'label ' => $ this ->l ('Disabled ' )
199+ ))
200+ ),
185201 ),
186202 'submit ' => array (
187203 'title ' => $ this ->l ('Save ' ),
@@ -191,6 +207,7 @@ public function displayForm()
191207 // Load current value
192208 $ helper ->fields_value ['GA_ACCOUNT_ID ' ] = Configuration::get ('GA_ACCOUNT_ID ' );
193209 $ helper ->fields_value ['GA_USERID_ENABLED ' ] = Configuration::get ('GA_USERID_ENABLED ' );
210+ $ helper ->fields_value ['GA_CROSSDOMAIN_ENABLED ' ] = Configuration::get ('GA_CROSSDOMAIN_ENABLED ' );
194211
195212 return $ helper ->generateForm ($ fields_form );
196213 }
@@ -213,6 +230,11 @@ public function getContent()
213230 Configuration::updateValue ('GA_USERID_ENABLED ' , (bool )$ ga_userid_enabled );
214231 $ output .= $ this ->displayConfirmation ($ this ->trans ('Settings for User ID updated successfully ' , array (), 'Modules.GAnalytics.Admin ' ));
215232 }
233+ $ ga_crossdomain_enabled = Tools::getValue ('GA_CROSSDOMAIN_ENABLED ' );
234+ if (null !== $ ga_crossdomain_enabled ) {
235+ Configuration::updateValue ('GA_CROSSDOMAIN_ENABLED ' , (bool )$ ga_crossdomain_enabled );
236+ $ output .= $ this ->displayConfirmation ($ this ->trans ('Settings for User ID updated successfully ' , array (), 'Modules.GAnalytics.Admin ' ));
237+ }
216238 }
217239
218240 $ output .= $ this ->displayForm ();
@@ -229,22 +251,29 @@ public function hookdisplayHeader($params, $back_office = false)
229251 $ shops = Shop::getShops ();
230252 $ is_multistore_active = Shop::isFeatureActive ();
231253
254+ $ current_shop_id = (int )Context::getContext ()->shop ->id ;
255+
232256 $ user_id = null ;
257+ $ ga_crossdomain_enabled = false ;
233258
234259 if (Configuration::get ('GA_USERID_ENABLED ' ) &&
235260 $ this ->context ->customer && $ this ->context ->customer ->isLogged ()
236261 ) {
237262 $ user_id = (int )$ this ->context ->customer ->id ;
238263 }
239264
240-
265+ if ((int )Configuration::get ('GA_CROSSDOMAIN_ENABLED ' ) && $ is_multistore_active ) {
266+ $ ga_crossdomain_enabled = true ;
267+ }
268+
241269 $ this ->smarty ->assign (
242270 array (
243271 'backOffice ' => $ back_office ,
272+ 'currentShopId ' => $ current_shop_id ,
244273 'userId ' => $ user_id ,
245274 'gaAccountId ' => Tools::safeOutput (Configuration::get ('GA_ACCOUNT_ID ' )),
246- 'multiStoreActive ' => $ is_multistore_active ,
247- 'shops ' => $ shops
275+ 'shops ' => $ shops ,
276+ 'gaCrossdomainEnabled ' => $ ga_crossdomain_enabled
248277 )
249278 );
250279 return $ this ->display (__FILE__ , 'ps_googleanalytics.tpl ' );
0 commit comments