Escaping Google Analytics Measurement Protocol Image
Hi,
I'm trying to put this code directly into one of my XML blocks:
<img src="http://www.google-analytics.com/collect?v=1&tid=UA-19988952-9&cid=bd809d48-63ef-4b0b-80c6-bbd154e7adf6&t=event&ec=email&ea=open&el=bd809d48-63ef-4b0b-80c6-bbd154e7adf6&cs=newsletter&cm=email&cn=062413&cm1=1" />
I do have a function set up that would escape any ampersands:
<xalan:component functions="encodeAmpersand" prefix="ss">
<xalan:script lang="javascript"><![CDATA[
var encodeAmpersand = function (input) {
return input.replace(/&(?!amp;)/g, '&');
};
]]></xalan:script>
</xalan:component>
What would be the best way to wrap the img code above with the function I have already created.
Thanks,
Nicole
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 03 Nov, 2015 03:58 PM
Hi Nicole,
You would need to pass the content of the block through your Xalan function. How you go about this depends on how you are including the block on the page. Are you using a Block chooser or adding it directly to the page region?
Thanks!
2 Posted by Nicole Foster on 03 Nov, 2015 07:14 PM
Hi Ryan,
I'm just adding directly into one XML block that generates an HTML newsletter in its entirety. The image is Google Analytics' 1x1 transparent pixel and we're using it to track email opens for our newsletters, so I need the image to be in the block itself instead of embedded.
Thanks,
Nicole
3 Posted by Ryan Griffith on 03 Nov, 2015 07:30 PM
Hi Nicole,
To confirm, are you adding the XML block directly to a page region, or is it being added using a block chooser?
If you are adding it directly to a page region, I believe you should be able to attach a simple Velocity Format to encode the ampersands:
Similarly, if you are using a block chooser you would just need to apply the
replaceAll
to the content of the block.Please let me know if you have any questions.
Thanks!
4 Posted by Nicole Foster on 03 Nov, 2015 07:33 PM
Hi Ryan,
We are adding it directly to a page region. The block itself is in XSLT.
Thanks,
Nicole
5 Posted by Ryan Griffith on 03 Nov, 2015 09:29 PM
Hi Nicole,
Should be doable using XSLT. When you have a moment, please attach the content of your XML block and I'd be happy to help with an XSLT format.
Thanks!
6 Posted by Nicole Foster on 03 Nov, 2015 09:51 PM
Hi Ryan,
I have attached the entire xml block in this post.
Thanks,
Nicole
7 Posted by Ryan Griffith on 04 Nov, 2015 02:41 PM
Hi Nicole,
It looks like you may have accidentally attached a Format. When you have a moment, please attach the XML Block's content.
Please let me know if you have any questions.
Thanks!
8 Posted by Nicole Foster on 04 Nov, 2015 03:38 PM
Hi Ryan,
I apologize immensely for the confusion.
The newsletter is generated only using a template and format block. The template is below:
and the format is what I attached above. There is no XML block attached. We only use the template, format, and what the user inputs into the data definition, which is below:
I have tried placing
into the template file, but that did not work as well. My only other option would be putting it into the XSLT format from my response above.
Thanks,
Nicole
9 Posted by Ryan Griffith on 04 Nov, 2015 06:38 PM
Thank you for the clarification, Nicole, I believe I am following now.
Will this hidden image ever change based on the email, or will it stay the same? Curious, but could you just place the
<img>
tag at the bottom of your template and escape the ampersands manually? So:Would be changed to:
Please let me know if you have any questions.
Thanks!
10 Posted by Nicole Foster on 05 Nov, 2015 03:04 PM
Hi Ryan,
That did the trick. I didn't think it would be as simple as that!
Thanks,
Nicole
11 Posted by Ryan Griffith on 06 Nov, 2015 08:41 PM
Thank you for following up, Nicole, I am glad to hear the adjustment 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 06 Nov, 2015 08:41 PM.