This is a code on the product page x and the product id is 56
sessionStorage.setItem("prodid", "%prodcode%");
I can call this product code on the y page using the code below
alert(sessionStorage.getItem("prodid"));
Comment: I will get a alert of 56
But what i want is to get the value of the product code in view source so that i can pass it to third parties like Google analytics.
For example:
_gaq.push(['_addTrans', '56', // product code 'Acme Clothing', // affiliation or store name '11.99', // total - required '1.29', // tax '5', // shipping 'San Jose', // city 'California', // state or province 'USA' // country ]);
The above analytics code is just an example.
console.log(sessionStorage.getItem("prodid"));(F12 Developer Tools, Firebug, Chrome Console, etc.)... - Cᴏʀʏ%prodcode%again. - nullabilitydocument.write(), but I would advise creating a node that you can append it to as a text node instead. - Joseph Marikle