This file contains hidden or 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
//This script needs to be fired on All Pages and/or before any AIDAX capture in GTM | |
<script> | |
var gtm = google_tag_manager[{{Container ID}}]; | |
try{ | |
// INSERT SCRIPT AIDAX: http://doc.aidax.com.br/ | |
gtm.onHtmlSuccess({{HTML ID}}); | |
} catch(e) { | |
gtm.onHtmlFailure({{HTML ID}}); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Experimento AIDAX</title> | |
</head> | |
<body> | |
<h1>Experimento AIDAX</h1> |
This file contains hidden or 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
//Iterate under array to add values with reduce() | |
var numbers = [0, 1, 5, 7, 3, 8, 9, 10]; | |
var total = numbers.reduce( function( sum, nextValue ) { | |
return sum + nextValue | |
},0) | |
// 43 |
This file contains hidden or 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
// Iterate under array to add values | |
var total = 0; | |
var numbers = [0, 1, 5, 7, 3, 8, 9, 10]; | |
for (var i = 0; i < numbers.length; i++){ | |
total += numbers[i]; | |
} | |
console.log("total ", total); | |
// 43 |
This file contains hidden or 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
// Example of map as a higher-order function because uses a callback function | |
var animals = [ | |
{ name: 'Fluffykins', species: 'rabbit' }, | |
{ name: 'Caro', species: 'dog' }, | |
{ name: 'Hamilton', species: 'dog' }, | |
{ name: 'Harold', species: 'fish' }, | |
{ name: 'Ursula', species: 'cat' }, | |
]; | |
// map all animals and his species | |
var names = animals.map(function(animal){ |
This file contains hidden or 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
// Capturing Event | |
// client-side JS | |
ax.event({ | |
name: "login", | |
properties: { | |
email: "[email protected]", | |
validation: true | |
} | |
}); |
This file contains hidden or 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
// Capturing Event | |
// client-side JS | |
ax.event({ // You can also use a concise format (ax({...})) | |
id: "EVENT ID", // pass this parameter if you have the event id to update it | |
name: "EVENT NAME", // obligatory | |
properties: { | |
property1: "foo", | |
property2: "bar" | |
}, // custom properties | |
callback: function(id) { |
This file contains hidden or 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
// Example of filter as a higher-order function because uses a callback function | |
var animals = [ | |
{ name: 'Fluffykins', species: 'rabbit' }, | |
{ name: 'Caro', species: 'dog' }, | |
{ name: 'Hamilton', species: 'dog' }, | |
{ name: 'Harold', species: 'fish' }, | |
{ name: 'Ursula', species: 'cat' }, | |
]; | |
var dogs = animals.filter(function(animal){ |
This file contains hidden or 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
// Using Function JS as a Value | |
var triple = function ( x ) { | |
return x * 3 | |
} | |
var waffle = triple | |
waffle(3) // 9 |
This file contains hidden or 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
// Session properties example | |
// client-side JS | |
ax.session({ | |
access_region: "São Paulo", | |
has_login: "true", | |
has_checkout: "true" | |
}); | |
// server-side HTTP request example | |
curl https://api.aidax.com.br/session?key=<key>&uid=<user id>&p={access_region:"São Paulo",has_login:"true",has_checkout:"true"} |
NewerOlder