I have some issue after add custom tag in GTM and setting configuration in magento by Weltpixel for GTM extension

so, i have custom tag for tracking event login, logout, banner click, brand click, etc in GTM for integration with Moengage.

all configuration is done and clear, can track these activity in GTM or Moengage, in my magento local site its can running perfectly, but different when deploy in staging site

actualy, for tracking these event i use $_SESSION


in observer set $_SESSION['userLogin'], enter image description here

then in default.phtml I get $_SESSION['userLogin'] and unset($_SESSION['userLogin']) enter image description here

in layout, i add this code for default magento template enter image description here

I checked, the result is: when the .phtml track before the unset($_SESSION['userLogin']) has a session, that's right after the unset($_SESSION['userLogin']) there is no session,

session history before unset with var_dump in console.log

array(11) {
  // other session
  &array(2) {
    array(2) {
      string(26) "[email protected]"
      string(10) "name example"

session history after unset

array(11) {
  // other session

its true, right ?

but, when the page is reloaded again in the .phtml track before unset($_SESSION['userLogin']) even there is a session again, that's right after unset($_SESSION['userLogin']) there is no session anymore

and so on, sometimes the $_SESSION['userLogin'] also disappears on its own

GTM result, double track (example if use event logout)

enter image description here

when checked in the observer section using logger, maybe there is a process 2 times setting $_SESSION['userLogin']

but, apparently not, only 1 time

enter image description here

why can it happen like that ? Can someone help me ? thank you

  • 1
    More than likely this is a FPC (full page cache) issue. To do something like this you would need to use the "Private content" and set various sessions. developer.adobe.com/commerce/php/development/cache/page/… Jun 17, 2022 at 17:03
  • Thanks for your answer, so the solution is just use private content ? Can't use session again ? But i have a question, why the session can be cached?
    – Ismynr
    Jun 17, 2022 at 18:42
  • You will have to use a session to temporarily store and then pass it to private content. Jun 20, 2022 at 16:57
  • yeah, thank you for your help, I have been I have solved it with private content, maybe this is the only way
    – Ismynr
    Jun 21, 2022 at 2:50


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.