简体   繁体   中英

How to track a link in wordpress post content with Google analytics?

Good day, I have a link in a post content, how can I track how many number of clicks when user is reading the article by Google Analytics ?

I don't want to use any plugins. I added the tag on Google Tag Manager and edited the link from :

<a href="https://test.com">Find out more</a>

to <a href="https://test.com" onclick="ga('send', 'event', 'HP Link', 'HP_Link', 'link');">Find out more</a>

and then save the post but the wordpress editor override and reset the link back to normal.

Is it possible to do this ??

If you have Google Tag Manager (GTM) installed and running on your site, then the easiest way is to set up event tracking within GTM.

To achieve this, you need to know, how to identify all the links you wish to track by these events, eg by having a common class on these links, or other CSS selectors can be used as well. You need this information to set up your trigger, which will fire a Google Analytics event tag, with your specific event category, action, and possibly other parameters.

For further details on GTM event tracking please refer to this step by step guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM