0
cfoutput within javascript
LEGEND
,
/t5/coldfusion-discussions/cfoutput-within-javascript/td-p/90386
Sep 03, 2008
Sep 03, 2008
Copy link to clipboard
Copied
Just trying to install the google ecom tracking code supplied
by google. It
does some nice things like the actual ROI depending on pay per click word
chosen.
Ive never had to output cold fusion varibles beofre within javascript. Do i
need to use use the toscript tag or would the code below work? Any help
appreciated.
<!----google e-com tracking--------->
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-1");
pageTracker._trackPageview();
<!------Output query results into javascript-------->
<cfoutput query="order2">
pageTracker._addTrans(
"#i_orderid#", // Order ID
"#d_grandtotal#" // Total
);
</cfoutput>
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
<cfoutput query="lines" >
pageTracker._addItem(
"#lines.i_orderid#", // order ID
"#lines.s_partno#", // SKU/code - required
"#lines.d_price#", // unit price - required
"#lines.i_quantity#" // quantity - required
);
</cfoutput>
pageTracker._trackTrans();
</script>
does some nice things like the actual ROI depending on pay per click word
chosen.
Ive never had to output cold fusion varibles beofre within javascript. Do i
need to use use the toscript tag or would the code below work? Any help
appreciated.
<!----google e-com tracking--------->
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-1");
pageTracker._trackPageview();
<!------Output query results into javascript-------->
<cfoutput query="order2">
pageTracker._addTrans(
"#i_orderid#", // Order ID
"#d_grandtotal#" // Total
);
</cfoutput>
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
<cfoutput query="lines" >
pageTracker._addItem(
"#lines.i_orderid#", // order ID
"#lines.s_partno#", // SKU/code - required
"#lines.d_price#", // unit price - required
"#lines.i_quantity#" // quantity - required
);
</cfoutput>
pageTracker._trackTrans();
</script>
TOPICS
Getting started
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/cfoutput-within-javascript/m-p/90387#M8978
Sep 04, 2008
Sep 04, 2008
Copy link to clipboard
Copied
If you want to know if the code works, run it.
There are a couple of ways to mix cold fusion variables with javascript. One is the to_script tag. The other is to surround the entire javascript block with cfoutput.
In your case, to_script seems like a better approach. Make each query column a js array.
There are a couple of ways to mix cold fusion variables with javascript. One is the to_script tag. The other is to surround the entire javascript block with cfoutput.
In your case, to_script seems like a better approach. Make each query column a js array.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/coldfusion-discussions/cfoutput-within-javascript/m-p/90388#M8979
Sep 04, 2008
Sep 04, 2008
Copy link to clipboard
Copied
Hi Dan
i did run the code and a part of it works. a transcation with google gets
recorded however all the other parameters are not recorded. I suspect this
is due to my syntax.
Im a hack and dont know too much about js arrays but from what ive been able
to find on the web, would it look something like this?
Should they be js variables do you think?
<!----google e-com tracking--------->
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-1");
pageTracker._trackPageview();
<!------Output query results into javascript-------->
<cfoutput query="order2">
pageTracker._addTrans(
var #toScript(i_orderid, "OrderID")#; // Order ID
var #toScript(d_grandtotal, "Total")#; // Total
);
</cfoutput>
"Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
news:g9oiia$t5s$1@forums.macromedia.com...
> If you want to know if the code works, run it.
>
> There are a couple of ways to mix cold fusion variables with javascript.
> One
> is the to_script tag. The other is to surround the entire javascript
> block
> with cfoutput.
>
> In your case, to_script seems like a better approach. Make each query
> column
> a js array.
>
i did run the code and a part of it works. a transcation with google gets
recorded however all the other parameters are not recorded. I suspect this
is due to my syntax.
Im a hack and dont know too much about js arrays but from what ive been able
to find on the web, would it look something like this?
Should they be js variables do you think?
<!----google e-com tracking--------->
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-1");
pageTracker._trackPageview();
<!------Output query results into javascript-------->
<cfoutput query="order2">
pageTracker._addTrans(
var #toScript(i_orderid, "OrderID")#; // Order ID
var #toScript(d_grandtotal, "Total")#; // Total
);
</cfoutput>
"Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
news:g9oiia$t5s$1@forums.macromedia.com...
> If you want to know if the code works, run it.
>
> There are a couple of ways to mix cold fusion variables with javascript.
> One
> is the to_script tag. The other is to surround the entire javascript
> block
> with cfoutput.
>
> In your case, to_script seems like a better approach. Make each query
> column
> a js array.
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/cfoutput-within-javascript/m-p/90389#M8980
Sep 04, 2008
Sep 04, 2008
Copy link to clipboard
Copied
I've only done this once, and since it had to do with a
frequent asked question (related selects), I made a web page.
http://www.pathcom.com/~bracuk/code/RelatedSelects.htm
Step 2 is where I create my cf arrays. Step 4 is where I convert and use them in js.
If you've not programmed in languages other than CF before, be aware that pretty much all of them start their arrays at element 0, unlike CF which starts at element 1.
Step 2 is where I create my cf arrays. Step 4 is where I convert and use them in js.
If you've not programmed in languages other than CF before, be aware that pretty much all of them start their arrays at element 0, unlike CF which starts at element 1.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
LATEST
/t5/coldfusion-discussions/cfoutput-within-javascript/m-p/90390#M8981
Oct 09, 2008
Oct 09, 2008
Copy link to clipboard
Copied
Thanks in advance for any feedback.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

