Reputation: 1002
I try to connect Google Tag Manager with Magento. On google site I find a couple of Data Layer Variable Names
.
<script>
dataLayer = [{
'pageCategory': 'signup',
'visitorType': 'high-value'
}];
</script>
Is there any site or place where can I find the name of magento Data Layer e.g.
Thanks for any advice.
Upvotes: 1
Views: 3478
Reputation: 217
GTM can use predefined macro names for the eCommerce transaction, like this:
<script>
dataLayer = [{
'transactionId': '1234',
'transactionDate': '13112012',
'transactionType': 'Type 1',
'transactionAffiliation': 'ACME Clothing',
'transactionTotal': 25.60,
'transactionShipping': 5.00,
'transactionTax': 1.00,
'transactionPaymentType': 'Paypal',
'transactionCurrency': 'EUR',
'transactionShippingMethod': 'Store pickup',
'transactionPromoCode': '',
'transactionProducts': [{
'id': '12',
'name': 'Red leather boots',
'sku': '45622LTHRBOOTS',
'category': 'Shoes > Boots',
'price': 450.00,
'quantity': 2
},
{
'id': '14',
'name': 'Black leather jacket',
'sku': '456VESRTE',
'category': 'Clothing > Jackets',
'price': 750.00,
'quantity': 1
}]
}];
</script>
Upvotes: 3
Reputation: 2446
As far as I understand it, in Google Tag Manager you work within a container, targeting one or all of your sites. Each container has its own datalayer (can be named however you like). In this datalayer you push variables and events, all of which are completely user-defined. This means there is no real "magento data layer", just THE datalayer, which contains the variables YOU have defined.
If your magento tag needs an sku value, you should define it in the datalayer yourself, ex.:
<script>
dataLayer = [{
'idSku': '102456',
'category': 't-shirt'
}];
</script>
This datalayer should be defined above your google tag manager script, otherwise these variables or events aren't available for the tag manager.
If you do want to add variables lateron, after a particular click-event for example, you could add it to the datalayer asynchronously using the following script:
dataLayer.push({'variable_name': 'variable_value'});
If you don't actually know what variables you need to define, you should probably read the magento documentation.
Upvotes: 1
Reputation: 44
As per my understanding on Google Tagmanager, You have to define the variable names in the GTM as Macros. If you don't have the access to google Tagmanager then ask Webmaster or Marketer orwho ever handles it to create the Macros you want. Then you can use the same names in your Magento code.
Let me know if this answers your question.
Upvotes: 0