XModPro

Using Field as Javascript parameter in Xmod Template

 Fenske Fenske posted Nov 3, 2014
Active Nov 26 · Viewed 1170 times

Hi Xmod experts,

Hoping you can help me with some syntax - I need to add a JavaScript call within an Xmod template in order to set some parameters of a function that configures some page tracking code.

I've added the primary tracking script to the xmod scriptblock for the template, but the provider company gave me instructions to add another embedded script line that will add a dynamic page title to the URL that is being tracked. In order to get that, I have to use the [[CourseTitle]] field returned by one of the queries in this template. 

So, in the <FooterTemplate> of that template block, I've added the following, based on instructions for the [Join()] function token I found on your site:

===========

<script>

[[Join("ewt.track({name:'{0}', Type:'Pageview'}",[[CourseTitle]])]]

</script>

=============

Here is the original script the provider gave me, minus the xmod additions:

<script>
ewt.track({name: 'Excel1', Type: 'Pageview'})
</script>

I basically need to replace 'Excel1' with the [[CourseTitle]] from this template.

Right now, it just crashes when the template loads. Can you tell me where I'm going wrong? My JS skills are pretty weak, so my apologies if I'm trying to do something ridiculous here.

Thanks! David

1 Reply

Loading replies...