Skip to content

Instantly share code, notes, and snippets.



Last active Oct 7, 2016
What would you like to do?
(function(t,r,a,c,k) { t[k]=t[k]||function(){ (t[k].q = t[k].q||[]).push(arguments) }
var ts=r.createElement(a);ts.type='text/javascript';ts.async=true;
ts.src=c; var s=r.getElementsByTagName(a)[0];s.parentNode.insertBefore(ts, s); })(window, document,
'script','//', 'my_track')
my_track('acessou página');
<a href="#" onclick="my_track('clicou no link');">Link</a>
(function() {
window['my_track'] = window['my_track'] || function() {
(window['my_track'].q = window['my_track'].q || []).push(arguments)
var tag_script = document.createElement('script');
tag_script.type = 'text/javascript';
tag_script.async = true;
tag_script.src = '//';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(tag_script, s);
<a href="#" onclick="my_track('clicou no link');">Link</a>
// FILENAME: my_async_plugin.js
(function () {
q = window['my_track'].q;
while(a = q.shift()){
console.log("desenfileira my_track");
my_track = my_real_track;
// função real
function my_real_track(params) {
// Fazer aqui a lógica de track (consumir api, etc..)
console.log("executa my_real_track");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.