Skip to content

mparticle-solutions/mparticle-gtm-idsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

IDSync Template

This GTM template allows for a customer to be logged in, logged out, or to be modified via your GTM implementation. This tag required the successful loading of the mParticle SDK to have been completed prior to this tag firing. This does require some additional set-up in comparison to other GTM tag templates, an identity callback function and user identities will need to be added to the data layer before the tag is triggered.

Steps to enable:

  1. Enable the data layer.
<script>
 
    //configure the data layer
    window.dataLayer = window.dataLayer || [];
    
</script>
  1. Add an identity callback to the data layer.
 <script>

    //add a custom identity callback to the data layer
    dataLayer.push({
        identityCallback: function(result) { 
            if (result.getUser()) { 
                // Do something once an identity call has been made.
                // For more information, see https://docs.mparticle.com/developers/sdk/web/idsync/#sdk-initialization-and-identify
                console.log(result);
            } 
        },
    });
    
</script>
  1. Add desired user identities to the data layer.
<script type="text/javascript">

        //this is an example function that runs when the login button is clicked. 
       function processIDSync(eventName){
            let email = document.querySelector('#email').value; 
            dataLayer.push({
                'userIdentities': {
                    'email': email
                }
            })
            
            //this is the example GTM custom event trigger for IDSync, please note that the identities are pushed before the trigger event. 
            dataLayer.push({'event': eventName'})
        }
    </script>
  1. Select the IDSync Template from the Google Community Template Gallery.
  2. Configure the tag with the desired IDSync event type.
  3. Configure the trigger to coincide with the login event.
  4. Deploy the tag.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages