I use Google Tag Manager & Analytics 4 in my Angular single-page application for measuring how many times particular Divs appear on the viewport. In this case, Div IDs are changing from time to time. Therefore every time each page loads, I'm sending those Div IDs to the dataLayer.
And in the Google Tag manager side by pulling dataLayer variables, I'm checking the Div IDs with the help of the Element Visibility trigger.
As you can see now dataLayer variables are assigned as I expected. (adSlot1- adSlot4) But the problem is when I compare these IDs in the Element visibility trigger, the trigger is not firing even though the Div is visible in the viewport.
These are my trigger properties.
Here {{adSlot1}} is the dataLayer variable name. ("adId-2" is the value, you can see it on 1st image) And when I add this "adId-2" manually like the below Element visibility trigger is working perfectly.
Since Div ID is not a constant, I cannot put a constant ID name as above, therefore I must add a variable.
So what I needed to know is the reason for this differences and a solution to overcome this issue.
Any help is much appreciated !! Thank you guys!


