ウェブサイトの注文受付ページにバリュー クリック トラッキング ピクセルを導入するよう依頼されました。データは 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>
上記で変数名を追加しようとしましたが、スペースと + 記号で囲みましたが、うまくいきません。ブラウザで上記を正確に表示しているだけです。
アイデアはありますか?