0

ウェブサイトの注文受付ページにバリュー クリック トラッキング ピクセルを導入するよう依頼されました。データは iframe の src に動的に配置する必要があります。

以下に示すように、変数として宣言された正しいデータを取得しました。

<script type="text/javascript">
//makes a copy of the total order revenue
var totalPrice = jQuery('.veryImportant.ordertotal div').html();
jQuery('#buttons').append('<p id="totalPrice">'+totalPrice+'</p>');
//removes the £ pound symbol from the duplicated string
var val = jQuery('#totalPrice').html();
jQuery('#totalPrice').html(val.substring(1, val.length));
//required variables
var orderid = jQuery('.ordernumber strong').text(); //order ID number
var revenue = jQuery('#totalPrice').text(); // total order revenue
var quantity = jQuery('#totalQuantity').text(); //quantity per table row/product name
//testing the variables print the correct values
alert(orderid + " " + revenue + " " + sku + " " + quantity);
</script>

(「sku」について疑問に思っている人のために、それはすでにページに存在しているので、私はそれで幸運です)

上記の jQuery の下に配置するこの iframe 内に変数の値を動的に出力する必要があります。

<iframe src="https://secure.img-cdn.mediaplex.com/0/24663/universal.html?page_name=sale&Sale=1&Amount={' + revenue + '}&Quantity={' + quantity + '}&mpuid={' + sku + ',' + orderid + '}" HEIGHT=1 WIDTH=1 FRAMEBORDER=0></iframe>

上記で変数名を追加しようとしましたが、スペースと + 記号で囲みましたが、うまくいきません。ブラウザで上記を正確に表示しているだけです。

アイデアはありますか?

4

1 に答える 1

0

わかりましたので、これを解決することができました。この方法はかなり長くなりましたが、残念ながら、いくつかのハードルを回避する必要がありました (そのため、一部のデータを複製して移動する必要がありました)。

<!-- order confirmation page VALUE CLICK -->
<venda_block mode=value,<venda_tpxt mode=get,name=track>=orderreceipt><!-- applies this     code block to the order receipt page only -->
<!-- HTML -->
<p id="valueClickSrc"></p><!-- acts as a store for the js to construct and deploy the dynamic src -->
<iframe id="iframe1" src="#" HEIGHT=1 WIDTH=1 FRAMEBORDER=0></iframe> <!-- the actual      tracking iframe which will be populated by js -->
<p id="totalQuantity" style="position:relative; z-index:9999; background:#066; font-size:14px; color:#FFF;"><venda_shopcart mode=getqty></venda></p><!-- serves to 'wrap' the quantity so that it can be selected by id -->
<!-- witch craft -->
<script type="text/javascript">
var totalPrice = jQuery('.veryImportant.ordertotal div').html(); //grabs the order total     price from the receipt and stores it in a variable
jQuery('#buttons').append('<p id="totalPrice" style="display:none;">'+totalPrice+'</p>'); //prints the total price inside a p tag so that it can be selected
var val = jQuery('#totalPrice').html(); //grabs the order total price from the newly printed p tag above
jQuery('#totalPrice').html(val.substring(1, val.length)); //removes the first character from the #totalPrice string (in this case, the unwanted £ GBP pound symbol)
var orderid = jQuery('.ordernumber strong').text(); //order ID number
var revenue = jQuery('#totalPrice').text(); // total order revenue
var quantity = jQuery('#totalQuantity').text(); //quantity per table row/product name
// sku is a variable that appears to already be in side the default checkout page js. I got lucky with that one.
alert(orderid + " " + revenue + " " + sku + " " + quantity); //tests that all variables are printing as they should
jQuery('#valueClickSrc').html('https://secure.img-cdn.mediaplex.com/0/24663/universal.html?page_name=sale&Sale=1&Amount=%7b'+revenue+'%7d&Quantity=%7b'+quantity+'%7d&mpuid='+sku+'id'+ orderid); //writes the dynamic url with a combination of text and variables. This is placed inside the <p> above called #valueClickSrc
var valueClickSrc = jQuery('#valueClickSrc').html(); //stores the content of the <p> above into a variable
jQuery('#iframe1').attr('src', valueClickSrc); //applies the content from #valueClickSrc into the src attribute of the iframe
</script>
</venda_block>
<!-- End Value Click tag -->

Venda プラットフォームで作業しているすべての人にとって、これは便利だと思うかもしれません。

誰か提案があれば、喜んで聞きます。

于 2013-03-28T16:28:41.163 に答える