Complete the following tasks to work with Google Tag Manager (GTM) and Acquia CDP:
S.No. | Task | Tag details |
---|---|---|
1 | Configure the Acquia Global tag | AgilOne - Global is a default essential tag for GTM. |
2 | Configure the Acquia Customer Object tag | AgilOne - Customer Object is a default essential tag for GTM. |
3 | Configure optional tags | The following are the default primary tags for GTM:
The following are the custom sample tags for GTM:
|
CDP uses an encrypted layer with a bcrypt salted key that must be refreshed daily to access and push payloads to the Acquia CDP API. The encrypted layer script must be added to the global tag so that it can auto-create the bcrypt key before getting fired daily, each time a customer engages on a webpage where GTM is added.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - Global.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the Acquia encrypted layer script:
<script>
var hashes = {"date": "bcrypt", "date"}
var today = new date().toISOSstring().slide(0,10);
var $A1Config = {
Key: hashes [today],
tenantId: ADD ID, host: "Acquia API URL"
};
</script>
<script>src="https://scripts.agilone.com/latest/a1.js"</script>
In Advanced Settings:
In Tag Sequencing:
Click Triggering and set the triggering process to fire the tag at All Pages as Page View.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - Customer Object.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the Acquia Customer Object script:
<script>
var visitor = {"id" : "{{GA - ClientID}}"};
If ("{{GA - Data Layer - User Email}}" != "unknown")
{
visitor.email = "{{GA - Data Layer - User Email}}";
}
var $a1vis = $A1.Customer(visitor);
</script>
In Advanced Settings:
In Tag Sequencing:
Click Triggering and set the triggering process to fire the tag at All Page Views - Window Loaded as Window Loaded.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - Login.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the Login script:
<script>
var $a1event = {type: "Login", customer: $a1vis};
$A1.Event($a1event).send();
</script>
In Advanced Settings, set Tag firing priority to 10.
Click Triggering and set the triggering process to fire the tag at User Logged In - Window Loaded as Window Loaded.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - PDP.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the PDP script:
<script>
var $a1prod = {productId: "{{PDP - Product SKU - JS}}"};
var $a1event = {type: "productBrowsed", customer: $a1vis, targets: $a1prod};
$A1.Event($a1event).send();
</script>
Click Triggering and set the triggering process to fire the tag at PDP - Window Loaded as Window Loaded.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - PDP - Add to Cart.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the PDP - Add to Cart script:
<script>
var $a1prod = {productId: "{{PDP - Product SKU - JS}}"};
var $a1event = $a1event({type: "cartUpdated", customer: $a1vis, targets: $a1prod});
$a1event.send();
</script>
Click Triggering and set the triggering process to fire the tag at PDP - Add to Cart as All Elements.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - PLP.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the PLP script:
<script>
var $a1cat = {SourceProductCategoryNumber: "{{Page Path}}"};
var $a1event = {type: "categoryBrowsed", customer: $a1vis, targets: $a1cat};
$A1.Event($a1event).send();
</script>
Click Triggering and set the triggering process to fire the tag at View Category - Window Loaded as Window Loaded.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - PLP - Add to Cart.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the PLP - Add to Cart script:
<script>
var $a1prod = {productID: "{{PLP - Quick Shop Opened - Product SKU - JS}}"};
var $a1event = {type: "cartUpdated", customer: $a1vis, targets: $a1prod};
$A1.Event($a1event).send();
</script>
Click Triggering and set the triggering process to fire the tag at PLP - Quickshop - Add To Cart as All Elements.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - Search.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the AgilOne - Search script.
<script>
var $a1search = {terms: "{{Site Search Term}}"};
var $a1event = {type: "onsiteSearch", customer: "Login", customer: $a1vis, targets: $a1search};
$A1.Event($a1event).send();
</script>
Click Triggering and set the triggering process to fire the tag at Search Page - Window Loaded as Window Loaded.
Click Save.
In the GTM user interface, click Tags > New.
Name the tag as AgilOne - Checkout.
Click Tag Configuration.
In Choose tag type, click Custom HTML.
In HTML, create the AgilOne - Checkout script.
<script>
(function(){
var _ix = { };
_ix.order = dataLayer[0];
_ix.orderId = _ix.order.transactionId;
_ix.total = _ix.order.transactionSubtotal;
_ix.price = [ ];
_ix.skus = [ ];
_ix.quantity = [ ];
_ix.items = [ ];
for(var x in _ix.order.transactionProducts){
_ix.items.push({
id: _ix.orderId + "-" + (x + 1),
type: "Purchase",
subType: "pending",
productId: _ix.order.transactionProducts [x].sku,
quantity _ix.order.transactionProducts[x].quantity,
saleRevenue: _ix.order.transactionProducts[x]. Price *
_ix.order.transactionProducts[x] . quantity,
discount: 0
});
}
var $tx = {id: _ix.orderId, type: "Purchase"};
var $a1event = {
type: "checkout",
customer: $a1vis,
transaction: $tx,
targets: _ix.items};
// $A1.Event($a1event).send();
})()
</script>
Click Triggering and set the triggering process to fire the tag at Checkout - Confirmation Page as Dom Ready.
Click Save.