Complete guide how to setup GA4 on Shopify

Step 14. How to implement GA4 login event on Shopify

Published by
Oct 26, 2022

One of the event that demonstrates engagement on the ecommerce and worth to measuring, is login event. 

We will implement here GTM tag that will be responsible for measuring login actions.

  1. Implement data layer variables in Shopify.
    In this step we implement login status data layer variables into Shopify template. These variables we use later in GTM to sent them to Google Analytics. You need to add following code into the section before GTM snippet:
    Shopify Admin>Online Store>Themes>Edit your template code>theme.liquid)

    Login data layer variables in Shopify

  2. Define new variables in Google Tag Manager
    Go to “Variables”

    GTM variables.

    then in “User-Defined Variables” section click “New” button

    GTM new user variable.


    a) Create “DL – login_status” data layer variable as follow (chose variable type as “Data Layer Variable”)
    data layer login status.

    b) Create “
    login_status_cookie” 1st Party cookie variable as follow (chose variable type as “1st Party Cookie”) to store current user login status

    login status cookie

  3. Create "login" trigger.
    Go to trigger section and create new trigger

    GTM new trigger.

    and create new “
    login” trigger as follow:
    GA4 login trigger .

    This trigger will fire every time when login status will change from not-logged to logged-in. 
    Create "Login status cookie tag" where current login status is assigned to login_status_cookie variable from DL – login_status variable on every page view as follow:
    login status cookie tag.

  4. Create "GA4 – login" tag using following settings and trigger that you have already created:

    GA4 login shopify tag.

    After this implementation you will be able to see in you GA4 reports statistics connected to login action.

    GA4 login report.

    Lets go to the next step of our guide which is: How to setup user ID for GA4 on Shopify.
Published Oct 26, 2022 by Piotr Ulacha

If you enjoyed the content please share it:

If you have any question about this topic feel free to comment or react below.

Other articles about Shopify
Complete guide how to setup GA4 on Shopify.

This guide is all about how to implement Google Analytics(GA4) on Shopify. To setup GA4 on Shopify website we use Google Tag Manger(GTM) and Shopify data layer.

Oct 12, 2022
1. How to create Google Analytics account for Shopify website

If you want to measure traffic on your Shopify website, the first thing is to create Google Analytics account for your website

Published by Piotr Ulacha
Oct 13, 2022
2. How to create Google Analytics (GA4) property for Shopify website

If you have Google Account but you don't have GA4 property yet, because for example you are still using Universal Analytics property (former version of GA4) you have to create new GA4 property.

Published by Piotr Ulacha
Oct 14, 2022
3. How to create Google Tag Manager account for Shopify website

Because we will use Google Tag Manger as a method to implement Google Analytics 4 you have to create GTM account.

Published by Piotr Ulacha
Oct 15, 2022

4. Recommended GA4 property settings for Shopify

If you want to get the best out of Google Analytics 4 apply the following recommended GA4 settings and best practices.

Published by Piotr Ulacha
Oct 16, 2022
Popular recently
Implementation of various environments in GA4
# GA4

Environment - is a set of necessary elements of technical / software infrastructure, which is the basis for the operation of a given website/application. Google Tag Manager environments are simply multiple versions of the same container. When we have a website with a different version for development, testing, production and QA, instead of creating separate GTM containers for each version, we can set up separate environments in the same container that will work independently in each version.

Published by Anna Bacciarelli
Jan 17, 2023
Server-Side GTM like a nuclear technology

Some time ago I listened to a podcast from the Technical Marketing Handbook series from Simo Ahava, whose guest was Adam Halbardier from the Google Tag Manager product team. During the conversation, the topic of transparency of data handled by the Server-Side container appeared.

Published by Mariusz Michalczuk
Dec 04, 2022
How to measure the impact of email campaigns?

If you plan email marketing campaigns you are interested in the same as with other campaigns, to measure their impact on your business. When you are starting with this topic it is good to know that without additional effort you will not be able to access this impact. You will see no results because Google Analytics will treat traffic from the email campaigns as direct traffic (when users are using your own app) or as referrals (when users are using web email clients). 

Nov 28, 2022