Support » Plugin: Google Tag Manager for WordPress » VisitorLoginState stopped working?

  • Hi Thomas!

    I have noticed on all my installs that suddenly Google Analytics script started to log my visits while I am logged-in, despite me excluding logged-in users.

    My setup:

    Data Layer variable: VisitorLoginState, Default value: logged-out
    Trigger: Pageview, VisitorLoginState equals logged-in
    Tag: The trigger above is set as an exclusion for Google Analytics.

    So the source code says dataLayer_content = {"visitorLoginState":"logged-in",...

    However, When doing a GTM preview, the variable is read as “logged-out”, despite I am logged-in.

    Strange. Is this just me?

    Thanks!

    • This topic was modified 2 months, 1 week ago by CroMisho.
    • This topic was modified 2 months, 1 week ago by CroMisho.
    • This topic was modified 2 months, 1 week ago by CroMisho.

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    Could you show me screenshots about your related tag and triggers?

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    The correct “Data Layer Variable Name” is visitorLoginState so the initial v is small caps and not capital V

    Oh Damn! true!

    I have double-checked all Containers and everywhere else the variable is correctly written. The issue still remains. It might be due to caching. I see that the Analytics tags gets fired on the first load, and then not on the second one. Very strange. These same accounts were working normally until recently.

    Oh, one more thing is new. Preloading. That might be it. The Flying Pages plugin…

    …nope, it seems it isn’t. Tag gets fired on all pages that are first time visited. Subsequent visits are ok. So it must be Siteground Supercacher. I think…

    I will play more with caching settings and report back if I find something.

    Thanks!

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Great, thanks for the additional insights, let me know what you have found so that other plugin users can also find an answer for similar cases.

    arthurrjw

    (@arthurrjw)

    Hi there – I’m also having this issue.

    It was working fine and then around the same time as CroMisho my visitorLoginState variable and visitorType variables have stopped working.

    On GTM preview I’m seeing: logged-out and undefined (respectively) despite being logged in as an administrator.

    This is causing a major upset in my data, please can we get this fixed ASAP?

    Thanks, Arthur

    N.B., I’m using WPEngine and WP Rocket (so totally different cacheing setup to CroMisho which would seem to make that an unlikely culprit).

    There’s also the fact that this was working perfectly and has only recently stopped working which could point to some kind of plugin update issue.

    • This reply was modified 2 months ago by arthurrjw. Reason: More detail on cacheing (see P.s.,)
    arthurrjw

    (@arthurrjw)

    UPDATE: Found the culprit. For some reason the boxes in Settings > Basic Data > Visitors had been unticked so the plugin wasn’t passing logged in status and user role to the data layer.

    I hadn’t needed (/don’t remember) having to activate these previously.

    Could this have been part of a recent update that either deactivated them accidentally or created the need to tick those boxes (or fixed an issue where the plugin was passing user data to the data layer regardless of whether they were checked or not)?

    In any case. I’m now getting the right variables and am able to exclude users in GTM accordingly.

    Hope that helps! A

    • This reply was modified 2 months ago by arthurrjw.
    • This reply was modified 2 months ago by arthurrjw.
    arthurrjw

    (@arthurrjw)

    Ok – the plot thickens.

    So, I now have an issue where visitor variables are NOT being passed to my initial page view tag but are being passed to all subsequent tags.

    See screenshots below:

    Not working on Page View: https://paste.pics/f3271f77228dea8892d6663d6410c91a
    Working on DOM: https://paste.pics/5b0ebb5ab4fb1c03ad182fd39692d4cc

    This means I’m not able to exclude the initial page view tag from firing based on visitorLoginState or visitorType variable (but I am able to exclude later tags using that data once it has loaded).

    Any ideas how to fix this Thomas? I’d like to be able to exclude administrator page views from all my analytics data.

    Thank you!

    N.B., I make live edits to my site and saw a big uptick in direct traffic starting November 7th so that could give a clue as to when the issue started.

    P.s., My enhanced e-commerce tracking via GTM4WP also stopped working around this time (battling with that as well) – not sure if it’s linked?

    • This reply was modified 2 months ago by arthurrjw.
    • This reply was modified 2 months ago by arthurrjw.
    • This reply was modified 2 months ago by arthurrjw.
    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    You have added a Global Site Tag into your website for a Google Ads account:

    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'AW-759285953');
    </script>

    Could you move this into your GTM container instead of adding it directly to your page source? I have the feeling that this is causing problems for you as it uses the same dataLayer object as GTM uses.

    Amazing – this appears to have fixed it.

    I was using the “WooCommerce Google Ads Conversion Tracking” plugin by Wolf+Bär Agency – legacy installation I hadn’t switched over after moving to GTM.

    Fix worked. Thank you for the quick and helpful feedback. 🙌

    Best, A

    P.s., Not sure if this was also CroMisho’s problem.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.