KDP
KDP

Reputation: 634

Track a single anchor link in Google Analytics

My client's website includes multiple product pages. On each, there is an option to "Contact Sales". This option is an anchor link that changes the screen to show the salesperson's contact information. The structure looks like this:

"http://www.example.com/products/detail/product-1.html" is the product page.

"http://www.example.com/products/detail/product-1.html#contactsales" is the anchor link that makes the sales information appear. The URL doesn't change.

I would like to track as a conversion any time someone clicks the "Contact Sales" anchor link on any product page. I have seen some solutions that will track all anchor link clicks, but I don't want to track any anchor links other than "Contact Sales", and then only as conversions. What is the easiest way to do this? Thanks!

Upvotes: 1

Views: 3304

Answers (1)

nyuen
nyuen

Reputation: 8907

This would be easiest if you attach your event directly to the anchor:

<a href="http://www.example.com/products/detail/product-1.html#contactsales" onclick="ga('send', 'event', 'Contact Sales', 'click');">Contact Sales</a>

Then you would be able to create an event goal around that.

Upvotes: 1

Related Questions