How to set up event clipping by clicking on a site link in Google Analytics? http://joxi.ru/BA01vMGiBnn61r

Found a solution on the Internet: It is necessary to tie up the onclick event by this example:

<a href="http://www.example.com" onclick="trackOutboundLink('http://www.example.com'); return false;">Открыть example.com</a> 

In my line

 <div class="coupon-code" cid="<?php echo $post->ID; ?>" data-clipboard-text="<?php echo get_post_meta($post->ID, 'coupon_code', true); ?>" pop-info='<?php echo $pop_info; ?>' aff-url='<?php echo $coupon_aff_url; ?>'><?php echo $print_text; ?></div> 

How to insert it correctly, so that the code worked out correctly and when you clicked on a link on the site there was a transition to a page in a separate tab

    1 answer 1

    You can simply add the code in onclick

     ga('send', 'event', 'event_category', 'event_action'); 
    • Which code exactly? - Beginner
    • In php, insert where you need the link, and the link itself with opening in a new window will look something like this: <a href = "" onclick = "ga ('send', 'event', 'event_category', 'event_action');" target = "_ blank"> link </a> - Ruslan Gr
    • so I don’t know how I’m going to my code <div class = "coupon-code" cid = "<? php echo $ post-> ID;?>" data-clipboard-text = "<? php echo get_post_meta ($ post-> ID, 'coupon_code', true);?> "pop-info = '<? php echo $ pop_info; ?> 'aff-url =' <? php echo $ coupon_aff_url; ?> '> <? php echo $ print_text; ?> </ div> put this correctly. Can you insert where necessary? - Beginner