Reputation: 21
I have the following code on a web page:
<a class="schedule-apt-btn" onclick="window.open('http://www.zocdoc.com/test');"> Appointment</a>
The URL that the window opens is populated dynamically and I want to be able to track clicks based on the URL. If the URL contains "zocdoc", i want to store that as one trigger. If the URL contains "hospital", I want to store that in another trigger.
How do I configure this? None of the preset event triggers (like Click URL) seem to work. Do i need to create a custom one? Any guidance would be great!
Upvotes: 2
Views: 1995
Reputation: 32780
Enable the built in {{Click Element}} variable and then write a custom JS variable that return the onclick attribute (e.g. via {{Click Element}}.getAttribute('onclick')). You will probably have to disable "Check validation" if you use a link click trigger. The reason {{Click URL}} does not work is that there is no href, hence no click url (and on a link trigger that checks validation this would not be considered a valid link).
Upvotes: 2