<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Adding event tags to links</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Adding-event-tags-to-links-80688</link>
        <description></description>
        <pubDate>Fri, 06 Mar 2026 12:20:15 -0800</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Adding-event-tags-to-links-80688" rel="self" type="application/rss+xml" />

                <item>
          <title>Adding event tags to links</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2239473#post2239473</link>
          <description><![CDATA[<p>Thanks so much Djulia.  I'll look into getting that on my server and test it!</p>]]></description>
          <pubDate>Mon, 29 Aug 2016 15:27:30 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2239473#post2239473</guid>
        </item>
                <item>
          <title>Adding event tags to links</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2239468#post2239468</link>
          <description><![CDATA[<p>Hi Tim,</p>
<p>You can use DOMDocument::loadHTML</p>
<p><code>$doc = new DOMDocument;<br />$doc-&gt;loadHTML(utf8_decode('&lt;div&gt;'.$record['content'].'&lt;/div&gt;'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);<br />   <br />// find all anchors<br />foreach ($doc-&gt;getElementsByTagName('a') as $anchor) {<br />  if ($anchor-&gt;hasAttribute('class') &amp;&amp; $anchor-&gt;hasAttribute('title')) {<br />    $attr = $anchor-&gt;getAttribute('class');<br />    if ($attr != 'trackThis') { continue; }<br />    $anchor-&gt;setAttribute("onClick", "ga('send', 'event', { eventCategory: 'Internal Page Links', eventAction: 'click', eventLabel: ".$anchor-&gt;textContent.", eventValue: Sample Title})");<br />  }<br />}<br />$html = utf8_encode($doc-&gt;saveHTML());<br />$new_html = preg_replace("/(^&lt;div[^&gt;]*&gt;|&lt;\/div&gt;$)/i", "", $html);<br />echo $new_html;<br /></code></p>
<p>LIBXML_HTML_NODEFDTD is only available in Libxml 2.7.8 and LIBXML_HTML_NOIMPLIED is available in Libxml 2.7.7...<br /><a href="http://www.php.net/manual/en/libxml.constants.php" rel="nofollow">http://www.php.net/manual/en/libxml.constants.php</a></p>
<p>Cheers,</p>
<p>Djulia</p>]]></description>
          <pubDate>Mon, 29 Aug 2016 01:20:29 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2239468#post2239468</guid>
        </item>
                <item>
          <title>Adding event tags to links</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2239467#post2239467</link>
          <description><![CDATA[<p>Hi All,</p>
<p>I'm wondering if there is some automated way of adding event tags to links created via the WYSIWYG field?</p>
<p>ie.  If a user created a link, added a title (Sample Title), then selected a class that I've added via the wysiwyg_custom.css (.trackThis), could I then have the outputted link be</p>
<blockquote>
<p>&lt;a href='linkURL' onClick="ga('send', 'event', { eventCategory: 'Internal Page Links', eventAction: 'click', eventLabel: '$recordTitle', eventValue: Sample Title});"&gt;</p>
</blockquote>]]></description>
          <pubDate>Sun, 28 Aug 2016 22:16:31 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2239467#post2239467</guid>
        </item>
              </channel>
    </rss>
  