adding a GA tag to a url
I have a request to add a GA tag to one slide in our main page slide show. The slides are 'created' in a xhtml block with a data definition and then styled with an xslt format.
The code should look like this:
<a href="http://www.uwo.ca/cleartheair/" onclick="ga('send', 'event', { eventCategory: 'Initiatives ', eventAction: 'Clicked', eventLabel: 'Clear the air', eventValue: 1});"><img alt="Let's Clear the Air" class="image" src="img/btn/initiatives/2015/cleartheair.jpg"/></a>
but I can't get the xslt to recognize the opening or closing brace brackets. They get translated to %7B and %7D. I've tried replacing them in the xhtml block with &#123; and &#125; but they still get changed once the page is rendered.
What am I doing wrong?
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 27 Jan, 2016 08:41 PM
Hi Judy,
Have you tried using
<xsl:value-of select="..." disable-output-escaping="yes" />
to see if that avoids the escaping?If you have, does the encoding occur when you test the format, or on page preview? If it looks fine when testing the Format, you could try surrounding the link with a
#protect
code section to see if that fixes the issue. In XSLT, this would look something like:Please let me know if you have any questions.
Thanks!
2 Posted by judy on 28 Jan, 2016 12:49 AM
Hi Ryan.
I'm getting closer. The brace brackets now work but the quotes are
causing problems.
Here's what I need to have:
<a href="http://uwo.ca/health/mental_wellbeing/letstalk/"
onclick="ga('send', 'event',{ eventCategory: 'Banner ', eventAction:
'Clicked', eventLabel: 'Lets talk banner', eventValue:1});"><img
alt="let's talk " src="img/slides/homepage/2016/bnr-mentalhealth-lg.jpg
<http://cms-tmp.uwo.ca/homepage/img/slides/homepage/2016/bnr-mentalhealth-lg.jpg>"/></a>
Here's the part of the format:
<a>
<xsl:attribute name="href">
<xsl:value-of select="website"/>"<xsl:value-of
disable-output-escaping="yes" select="tracking"/>
</xsl:attribute>
<img>
<xsl:attribute name="src"><xsl:value-of
select="photo/path"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="alt_tag"/></xsl:attribute>
</img>
</a>
Here's the piece of code that is in tracking:
onclick="ga('send', 'event',{ eventCategory: 'Banner ', eventAction:
'Clicked', eventLabel: 'Lets talk banner', eventValue:1});
Here's what the source code of the published page has:
<a
href="http://uwo.ca/health/mental_wellbeing/letstalk/"onclick="ga('send',
'event',{ eventCategory: 'Banner ', eventAction: 'Clicked', eventLabel:
'Lets talk banner', eventValue:1});
<http://uwo.ca/health/mental_wellbeing/letstalk/%22onclick=%22ga%28%27send%27,%20%27event%27,%7B%20eventCategory:%20%27Banner%20%27,%20eventAction:%20%27Clicked%27,%20eventLabel:%20%27Lets%20talk%20banner%27,%20eventValue:1%7D%29;>"><img
alt="let's talk " src="img/slides/homepage/2016/bnr-mentalhealth-lg.jpg
<http://cms-tmp.uwo.ca/homepage/img/slides/homepage/2016/bnr-mentalhealth-lg.jpg>"/></a>
Any ideas?
Thanks.
Judy
3 Posted by Ryan Griffith on 28 Jan, 2016 12:32 PM
Hi Judy,
If I am following, are you outputting both the URL and the tracking code within the
href
attribute? If so, I would recommend something more like the following:Note: You would need to adjust the value entered into the tracking field to no longer contain the
onclick=""
portion, but everything else should be able to remain the same.Please let me know if you have any questions.
Thanks!
4 Posted by judy on 28 Jan, 2016 03:13 PM
Thanks, Ryan. That did the trick!
5 Posted by Ryan Griffith on 28 Jan, 2016 05:07 PM
Thank you for following up, Judy. I am glad to hear the proposed change did the trick.
I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.
Have a great day!
Ryan Griffith closed this discussion on 28 Jan, 2016 05:07 PM.