Last active
October 22, 2019 14:11
-
-
Save shabbirbhimani/2730d3ed7914df353bb08dbcf963412a to your computer and use it in GitHub Desktop.
Tracking Clickbank Sales into Google Analytics E-Commerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cb_item=$_REQUEST['item']; | |
$cb_affiliate=$_REQUEST['cbaffi']; | |
$cb_receipt=$_REQUEST['cbreceipt']; | |
$cb_cname=$_REQUEST['cname']; | |
$cb_cemail=$_REQUEST['cemail']; | |
$cb_ccountry=$_REQUEST['ccountry']; | |
$net_amount = 19.97; | |
if($cb_affiliate!='0') $net_amount = 0.3*$net_amount; | |
?> | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXXXX-XX']); | |
_gaq.push(['_trackPageview']); | |
_gaq.push(['_addTrans', | |
'<?php echo $cb_receipt; ?>', // order ID - required | |
'XXXXXXXX', // affiliation or store name | |
'<?php echo $net_amount; ?>', // total - required | |
'0', // tax | |
'0', // shipping | |
'Any', // city | |
'Any', // state or province | |
'<?php echo $cb_ccountry; ?>' // country | |
]); | |
_gaq.push(['_addItem', | |
'<?php echo $cb_receipt; ?>', // order ID - required | |
'999', // SKU/code - required. | |
'XXXXXXXXXXX', // product name | |
'ebook', // category or variation | |
'<?php echo $net_amount; ?>', // unit price - required | |
'1' // quantity - required | |
]); | |
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers | |
(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); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment