Last active
March 13, 2017 15:21
-
-
Save luigi7up/b3ac164683a68c6afc323912f29f18e6 to your computer and use it in GitHub Desktop.
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
//1. Initialize amplitude | |
// between the <head> and </head> | |
<script type="text/javascript"> | |
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script");r.type="text/javascript"; | |
r.async=true;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.4.0-min.gz.js"; | |
r.onload=function(){e.amplitude.runQueuedFunctions()};var i=t.getElementsByTagName("script")[0]; | |
i.parentNode.insertBefore(r,i);function s(e,t){e.prototype[t]=function(){this._q.push([t].concat(Array.prototype.slice.call(arguments,0))); | |
return this}}var o=function(){this._q=[];return this};var a=["add","append","clearAll","prepend","set","setOnce","unset"]; | |
for(var u=0;u<a.length;u++){s(o,a[u])}n.Identify=o;var c=function(){this._q=[];return this; | |
};var p=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]; | |
for(var l=0;l<p.length;l++){s(c,p[l])}n.Revenue=c;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","logEventWithTimestamp","logEventWithGroups"]; | |
function v(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0))); | |
}}for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){e=(!e||e.length===0?"$default_instance":e).toLowerCase(); | |
if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]};e.amplitude=n; | |
})(window,document); | |
amplitude.getInstance().init("YOUR_API_KEY_HERE"); | |
</script> | |
//2. Identify user | |
amplitude.getInstance().setUserId('USER_ID_HERE'); | |
or | |
//When initializing | |
amplitude.getInstance().init('YOUR_API_KEY_HERE', 'USER_ID_HERE'); | |
// 3.Register custom props | |
//just before the </body> | |
var eventProperties = { | |
'client': private | company|corporate, | |
'client_id': xxx, | |
'client_size': [0-10" | "10-25"..., | |
'client_country': "ES" | "xxxx", | |
'user_can_manage': [true|false], | |
... | |
}; | |
amplitude.getInstance().logEvent('EVENT_IDENTIFIER_HERE', eventProperties); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment