Expand my Community achievements bar.

Google Tag Manager in AEM to get number downloads on a website.

Avatar

Community Advisor

9/20/22

Company Name: Rightpoint

Company URL: https://www.linkedin.com/company/rightpointindia/

Your Name: Nikhil Kumar

Your Title: AEM Lead

 

Requirement is to track the download of any doc or pdf from your web application.
To track this we will use GTM and Google Analytics along with AEM codebase.

So GTM (Google Tag Manager) is a free service provided by Google. So we will create a container in GTM. You can go to https://tagmanager.google.com/?hl=en#/admin/accounts/create to create GTM container and give the container name and choose Target Platform as Web
C561B4F4-1874-4DD8-963A-DC613DAF629B.jpeg

 

 

Now on your GTM dashboard, go to variables and add some click variables:
D48A7976-4E46-4841-9039-E5B001FA84CC.jpeg

Now we will create Tags and Triggers to track the event. Now navigate to Tags option on GTM Dashboard and create a Event with following fields and values.
Select Tag Type as Google Analytics : Universal Analytics
EA21C8C5-21DF-4359-A0C4-EA3891C5A568.jpeg

 

 


Google Analytics Settings variable needs to be created using the tracking id from Google Analytics which can be obtained from going to Google Analytics dashboard and Admin. Then Tracking Info > Tracking Code. Copy the ID that looks like this UA-XXXXXX-XX and paste it to the Tracking ID field in GTM.

Now we will create a trigger which will be attached to this tag that we created above. Create a trigger of type Just Links.
60DEFA25-2D79-445D-8B8D-E5BB80432F2D.jpeg

 

 

Add the type of files you want to track. Once whole configuration is done then publish the tag created and go to Admin in GTM and open Install Google Tag Manager and copy paste the scripts in the head.html and the body.html of your project.

As I am using AEM SPA code setup so I pasted it in my body.html and customheaderlibs.html

After pasting the script snippet in code base and publishing the tags now once you click/download any pdf or doc it will track it as part of Google Analytics reports. You cam go to Google Analytics dashboard and go to Realtime and then Events, it would be logged there.

 

 

 

@kautuk_sahni  @Jagpreet_Singh_  @VeenaVikraman 

 

Aspire Experience Manager Target