Adding onclick events to Ephox inline links

We’re trying to insert an onclick attribute of the form onclick=”RedEyeTag(‘x1/x2/x3/x4’)” to an inline link anchor tag in Ephox. The attribute saves fine and can be seen in the code view, but the attribute disappears when the page is published, ie when the context.

Would anyone know if it’s possible to stop that happening? I understand we should probably use an inline template but this would be good to know anyway.

Found the solution - add the following lines within sys_inlinelinks.xsl (well copy over into rx_inlinelinks.xsl):

<xsl:variable name=“temponclick” select=“substring-after(@href,‘onclick=’)”/>
<xsl:choose><xsl:when test="$temponclick!=’’"><xsl:attribute name=“onclick”>$temponclick</xsl:attribute></xsl:when></xsl:choose>

Xsl assembler uses sys_InlineLinks.xsl for stripping out certain Rhythmyx added attributes while rendering the xsl variants, but velocity assembler does not use this file. What assembler are you using?

Hi there.
Still trying to find out how Velocity processes inline links (not using sys_inlinelinks.xsl)(same unanswered q in thread
If anyone has an idea, much appreciated…

  • I

an update from TS … “In the current product, there is no equivalent to sys or rx inline links xsl in velocity. The processing is done in the assembly engine on the server side.”

So you cannot add onclick attributes to inline links in 6.x…? That’ll suck if you want to use Google Analytics to track external links, for example. There are ways round these things, but you’d think a CMS would support basic web development techniques that have been around for more than a decade. I mean, this isn’t exactly bleeding-edge Web 2.0 stuff - Netscape 2.0, more like.

We’ve been trying to add onclick events to inline links in Rhythmyx 6.7 to make use of Google Analytics and the marketing department in our organisation/organization is applying pressure on us to put this in place quickly. Is there now a means by which this can be done - I’m reluctant to say we can’t without having fully researched this and without having a tangible reason as to why we can’t?

Is there any reason you can’t add it to the snippet template? We have a variable for each site for a “google analytics id” that if it exists, will track clicks on certain links (ie external and links to files… we do not track internal page clicks as we figured that google would do that for us). For other specific tracking purposes, users have been able to add the “onclick” code themselves via the “view > html” method.

Granted, it would be nice if there was an “automagic” way to do it that could be customized in a better interface (ie. figure out how we want each click tracked, specific tracking code etc) .

On further reading you did say “inline links”, so a potential solution to this would be a javascript function that adds the “onclick” attribute to the links. Obviously you can make that function as smart (ie detect if is an external site, if it is a link to a file, etc) or a simple (add that code to all links on the page) as needed / wanted. This method unfortunately doesn’t allow you to track specific goals…

Thanks for getting back to me so quickly. The javascript option is one we’re keen to implement shortly and I’ll take a look at snippet templates now…

No problem! Just keep in mind that when you say “inline links” that is not the same as “inline templates” to me (as the latter is affected by snippet templates whereas the former is not… which is why I had to amend the original post saying that you should modify the snippet templates :wink: )