Set up AddThis social tracking using GTM

AddThis social shares

In my previous five articles, we have learned how to implement Google Tag Manager, added Google and Facebook Pixel tracking code,  Set up conversion tracking, how to Set up event trackingSet up Scroll Tracking using Google Tag Manager and Set up video tracking using Google Tag Manager. Today, I am going to show you how to set up AddThis social shares tracking.

What is AddThis

It is a web widget that integrated into your website that users can use to share your content with their social media platform.

Why do we need this since AddThis has its Analytics?

Yes, you are right. You don’t need to do this at all. But isn’t it is easier to see everything using one platform?

AddThis social shares tracking configuration

  1. Login to your Google Tab Manager account.
  2. Let create three Data Layer Variables first. Click variable then click New.

    AddThis social shares create new variable

  3. Give a proper name to your variable. Let name it Addthis socialAction. Then click the variable configuration.

    addthis name it social action

  4. Click on Data Layer Variable.

    addthis select add layer

  5. Give a proper name for your Data Layer Variable Name. I name it div – AddThis socialAction. Then click Save.

    addthis data layer variable name

  6. Repeat this two more times. Give it a name AddThis socialNetwork and AddThis socialTarget.

  7. Let click Tags, then click New.

    create new tag

  8. Give a proper name to the Tag. I name it GA – AddThis – Social interaction. Click on the Tag Configuration section.

    ga addthis social interaction

  9. Select Google Analytics: Universal Analytics.

    select google analytics

  10. Under Track Type, select event. For Category, select AddThis socialNetwork. For Action, select AddThis socialAction. Finally, select AddThis socialTarget under Label. After that click Triggering section.

    ga addthis social interaction tag

  11. Click the add icon.

    AddThis social shares click add icon

  12. Give a proper name for the new trigger. I name it Custom – socialinteraction. Then click on Trigger Configuration.

    new the trigger 1

  13. Select Custom Event.

    select custom event

  14. Give a proper event name such as addThisSocialInteraction. Then click save.

    name this trigger event name

  15. Click save

    click save

  16. Let create another Tags, click New

    create another new tag

  17. Name your new Tag, Custom addThis Event Listener, click on Tag Configuration.

    custom addthis event listener

  18. Select Custom HTML

    select custom html

  19. Paste the following code, after that click on Triggering.

    <script>
    function addThisEventHandler(evt) {
    switch (evt.type) {
    case “addthis.menu.share”:
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
    ‘event’: ‘socialInteraction’,
    ‘socialNetwork’: evt.data.service,
    ‘socialAction’: ‘Share’,
    ‘socialTarget’: evt.data.url
    });
    break;
    }
    }
    addthis.addEventListener(‘addthis.menu.share’,
    addThisEventHandler);
    </script>

    field up the html and click triggering

  20. Give your new Trigger a proper name, Pageview – DOM Ready.

    give the tag a name click trigger

  21. Select Dom Ready.

    select dom ready

  22. Click save.

    click save 2

  23. Save it again.

    click another save

  24. Click Submit.

    click submit

  25. Name your version and description then click Publish.

    click publish



Share

facebook icon twitter icon linkedin icon what app icon

Comments