I got asked by a client using GA/GTM to track return visits with an event.
Here’s how I did it.
Paste the following lines after the Cookies block. Note the dataLayer.push() call – there are two variables. “event” is a built in variable. The value “Intent” was specified by the client. You can call it whatever you like. (Also needs to be in <script> tags.)
Set up your trigger as a Custom Event. I have set the variables Event and Action as per the values that I am firing in the client side JS.
Set up the tag.
Test by clicking on Preview.
The script above sets a timer for 2 hours (120 minutes). For the purposes of testing, you could lower that to 3 or 5 minutes.
Clear any website cache if you need to.
Visit a couple of pages and check console to verify the script is running (should tell you how many minutes since your last visit once you have visited the second page).
Set a timer and test after your timeout and you should see the following tag fire.
If this helps you, please post in the comments below!