Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="P3P" content='CP="CAO PSA OUR"'><!-- This encourages IE to track 3rd Party content/cookie. -->
- <title>Secondary Domain : iFrame Test Page V2</title>
- <!-- Inside the iFrame the JavaScript needs to be above the links/content Google recommends just above </head> -->
- <script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-XXXXXXXX-8']); // Same Google Analytics account as iFrame parent
- _gaq.push(['_setAllowLinker', true]);
- _gaq.push(['_setDomainName', 'none']); // none = correct, set to overide secondary domain actual value
- _gaq.push(['_trackPageview']); // Must track page view before tracking transaction
- // E-commerce specific tracking requires up to 3+ pushes, must be on the completed sale page in header.
- // Push one is the transaction
- // Not all arguments are required but it is necessary to at least send an empty string '' as the number of arguments matters
- _gaq.push(['_addTrans',
- '12224', // transaction ID - required
- '6042021561', // affiliation or store name
- '275.50', // total - required
- '26.50', // tax
- '10.00', // shipping (transaction) fee
- 'Surrey', // city
- 'British Columbia', // state or province
- 'Canada' // country
- ]);
- // One push for each item in the transaction shopping cart
- _gaq.push(['_addItem',
- '12224', // transaction ID - required, should match transaction ID in push above
- 'Brave New World', // SKU/code - required MOST SPECIFIC
- 'Fiction', // product name MOST PROMINANT in Google Analytics
- 'Books', // category or variation BROADEST
- '132.50', // unit price - required
- '2' // quantity - required
- ]);
- // Final transaction related push
- _gaq.push(['_trackTrans']);
- (function() {
- var ga = document.createElement('script');
- ga.type = 'text/javascript';
- ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(ga, s);
- })();
- // In the Google Chrome Analytics debugging plugin this will show as 4 seperate tracking beacons sent.
- </script>
- </head>
- <body>
- <p>
- Text inside of an iFrame on another domain, in order to track links to this page consider using:
- <pre>
- onclick="_gaq.push(['_link', this.href]); return false;"
- </pre>
- </p>
- <ul>
- <!-- As a bonus here is how to fire an onpage event, this will send another tracking beacon back to the mothership -->
- <li><a href="#" onClick="_gaq.push(['_trackEvent', 'Videos', 'Play', 'Played Product Video']); return false;">Track Event inside iFrame</a></li>
- </ul>
- <!-- FYI there is also a _linkByPost for form submission and a _trackSocial event, they are less simple to demo -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment