Home / Integrations / Mailchimp / Mailchimp user tracking in Google Analytics using Google Tag Manager
Mailchimp User ID Tracking

Mailchimp user tracking in Google Analytics using Google Tag Manager

The problem:

When you have great analytics on your Mailchimp email data, at times you want to also track what each individual user is doing within Google analytics for a more in-depth understanding of how each individual behaves before converting. Google has provided us with a great free tool, Google Tag Manager to simplify this without using code.

Implementation time: 15 Minutes

Prerequisites:

  • Google Analytics installed on your website
  • Google Tag Manager installed on your website
  • Mailchimp as your email marketing service 

The solution:

The solution is to use the EID (email address ID) from Mailchimp and pass it to a Custom Dimension within Google Analytics.

Step 1: Create the Custom dimension withing Google Analytics

Within google Analytics Navigate to Admin > Custom Definitions > Custom Dimensions 

Create a new custom dimension called Visitor ID with the Scope set to User

Step 2: Create the trigger, variable and tags in GTM

Create the Variable:

Inside Google Tag Manager, First create a new Variable using the URL and selecting the component type Query String.

Finally we set the variable for the Query Key as mc_eid

Create the trigger:

We only want this rule to execute when the mc_eid is detected in the full URL path after someone clicks on a Mailchimp email link.

For this, create a new Trigger to fire on the Page URL when it contains the query variable mc_eid

Create the tag:

Finally we want to create the tag which pushes the mc_eid to Custom Variable 1 inside Google Analytics.

  • Choose Product: Google Analytics
  • Choose Tag Type: Universal Analytics
  • Configure Tag:
    • Tag Type: Universal Analytics
    • Tracking ID: UA-XXXXXX (your GA tag)
    • Tracking Type: Page View
    • Custom Dimensions: If this is your first tag, then enter in the Index number as 1, followed by {{MC EID}} which is your custom variable created in the first step.
  • Fire On: Some Pages > Select the trigger created in the previous step.

(Don’t forget to publish your GTM container after all the above steps have been completed)

Step 3: Set Mailchimp to use eCommerce360 Link Tracking

For every new campaign you send, ensure eCommerce360 Link Tracking is enabled. By doing this, Mailchimp will appended mc_eid=xxxxxx to every click within your emails. If you have automation running on campaigns, simply go back and update this option so future campaigns are sent with the EID of the user.

Step 4: Test out your new tag!

A quick and easy test will be to enter your website address with a random mc_eid. Alternatively you can create and send out a mailchimp campaign and click the link to ensure the mc_eid variable is being correctly passed.

Example: http://www.yourwebsite.com/?mc_eid=123456

Step 5: Check Visitor ID in Google Analytics

Within Google Analytics click on your Custimzation tab and create a new report.

Create a new report (or use an existing one) and set your Primary Drill Down dimension to the Visitor ID

It may take up to 1 hour for new visitor data to appear, but once it does you should see something like the following.

  • Was this Helpful ?
  • yes   no

About The Moo Master

As today's world moves towards more cloud based solutions, it's not always easy to find an all-in-one solution to a business problem. We focus on business development. finding new, creative and innovative ways to use different IT systems to enhance and automate business processes. We're happy to share our knowledge and solutions we've come up with over the years to some of those unique IT/Business problems.

22 comments

  1. I think mailchimp have changed their tracking id.

    Please find the new tracking address:

    http://balaxi.us9.list-manage.com/track/click?u=37f3ecfd5ce5a1c6bc03f86c1&id=80e1e24b76&e=dd5407ad5a

    As you can see that mc_eid have missing, I think it has changed to e=…..

    Is there any updated solutions for this?

    • Hi Matthew,

      The link you’ve got there is the mailchimp link to track the click – once you click on the link, you will then see the mc_eid. Below is when i click the link above – you will notice the mc_eid at the end of the email.

      utm_source=Syringe+list+demo&utm_campaign=3318dffadb-who_we_are_11_6_2015&utm_medium=email&utm_term=0_4d68586f03-3318dffadb-319919317&ct=t(who_we_are_11_6_2015)&mc_cid=3318dffadb&mc_eid=dd5507ad5a

  2. Thanks for the post. As a matter of interest, why are you sending the custom dimension with a pageview tag rather than an event tag ? Would the pageview tag increase the number of pages?

    • The one reason was events (as far as i’m aware) could not be configured for goal tracking, where as page views could be. (Correct me if i’m wrong). I would love to hear your take on it also as to pageview vs event for the UserID tracking.

  3. Events can be used to create goals in Google Analytics – this might also remove the concern about creating two pageviews. The only thing would be to ensure the event is a non-interaction hit as it would impact bounce rates (actually two page views would impact bounce rates as well)

    • I would have to agree with you there for the double pageview – I keep thinking there was a reason i choose pageview over event…. for the life of me i can’t remember why now. But i do agree, event tracking seems to be the way to go.

      If you’re implementing this solution using event tracking, can you let me know your feedback and any limitation using event tracking over pageview for MC UID tracking. It might help jog my memory why i choose it in the first place.

      • How would you go about changing it from a pageview to an event?

        • Hi Katie,

          I believe there are some limitations using Events vs PageView (from memory you can’t drill down into pages per session using an event). I also don’t think Events support a custom dimension which is why a PageView is used. I understand that it’s adding another PageView for each session where the URL contains the mc_eid tag. In theory this does skew your pageview stats. The only work around would be to look at another solution like using the mc_eid, setting a dataLayer variable and then using GTM to set the UserID in google analytics. https://support.google.com/tagmanager/answer/4565987. That way it won’t record an addition pageview, rather it will simply associate sessions for that user with the correct UserID in google analytics (different concept we’re talking about here)

          • Thanks!

            I have everything set up for Pageviews; however, GA isn’t showing the mc_eid like in your photographed example but rather only {{UNIQID}}. Do you have any idea what I could be doing wrong?

          • Hi Katie,

            I would suggest double checking the tag is working in google tag manager. You can do this by opening google tag manager > Enter “Preview Mode”.

            Load your website (www.example.com/?mc_eid=123456789) which will force the tag to fire. The output should look something like the following. If it doesn’t, then you will need to re-check the configuration in GTM.

            GTM Tag has fired?
            Then click to expand the tag to see that it has the correct MC_EID.
            Check the MCEID

  4. Praveen Prabhakaran

    I had done exactly as you have suggested. I see the data in Visitor ID as http://mywebsite.com/menu/?mc_cid=8a63505ff5&mc_eid=bc86b0dbf6 in Google analytics.

    The link works perfect. But, I don’t see the data that you show in Visitor ID, like the numbers you have on your data as metrics.

    I also tried to use the PII viewer for Google Analytics and it is not displaying the emails or user Id.

    Can you please tell me what or where am I going wrong.

  5. Hi there,

    Is the mailchimp EID anonymous on the Mailchimp side or can you see which EID belongs to which user?

    Also, what are some scenarios you have for when this information is valuable?

    Thanks for sharing! Very easy to follow.

    Kim

  6. Hi,
    Nice post!
    To prevent the “double pageviews” problem, why just no place an exclusion for URLs with “mc_eid” in the basic GA tag? Do I miss someting doing that?

    Thanks!

    • Hi Bernard – I believe in doing so you will also exclude the PageView from ever being recorded. Now I think about it, you might be able to customize to send the PageView and Dimension at the same time. This might require some changes to your current Google Analytics implementation. Example: Only fire standard pageview tag when the mc_eid is NOT present, and another tag to fire when the mc_eid is present. I haven’t tested this, just a quick thought off the top of my head.

    • Sorry Bernard, just re-read your comment – I thought you were talking about an exclusion rule in google analytics and not the tag. What you described (and then i accidentally re-described) sounds like the perfect solution 🙂

      This would only be useful if you are already using GTM to fire your standard GA tag.

  7. When I create the Visitor ID custom dimension, the right bar says, “copy the following code snippet for your platform. DO NOT FORGET to replace dimensionValue with your own.”

    JavaScript (Only works for Universal Analytics properties)
    var dimensionValue = ‘SOME_DIMENSION_VALUE’;
    ga(‘set’, ‘dimension1’, dimensionValue);

    What is this all about?

    What should I replace dimensionValue with?

    I followed all the instructions and my custom report is not showing the Visitor ID as expected.

    At least I CAN see the mc_eid listed in the URL’s under a section called: “What pages do your users visit?” listed like this:

    Page Pageviews Page Value

    …html?mc_eid=123456 14 $0.00

    • Hi Rob,

      The custom dimension should be what you’ve created in step 1. The value for that dimension will be the MC_EID
      Check out step 1

      Please confirm you are also using Google Tag manager to set the dimension as well? In your example you have a copy paste of the Javascript (which if course works as well). Google Tag manager simply takes out the complexity of having to write your own functions to pull in the MC_EID.

      If the custom dimension has been created, then it will be visible in Google Analytics drill down regards (regardless of if there is data present or not).

      Hope this helps.

  8. Hi! Do you know if your step-by-step instructions still work with GTM? My dev tried to follow it but he says GTM doesn’t look the same. He says “The instructions don’t match the new GTM screens, so I’m having troubles getting that working. The end of step 2 is where it gets sketchy.”

    If there’s been a recent change, can you help direct us on how to proceed to complete the Mail Chimp set up? Thanks!

    • Hi Yvette,

      There have been some major changes to the way GTM looks now, but the steps should remain the same throughout the process. You will still need to create the variable followed by the trigger and finally combine it all into the tag.
      Hopefully the below screenshots help.

      Trigger

      Trigger

      Tag

  9. How can we leverage this data in a Google Data Studio report? I’m not sure what to put in GDS as a dimension to show the results of this custom dimension and GTM tag?

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *