Reputation: 1121
I'm just setting up eCommerce with GTM. I need to pass purchase events to GTM. Right now I'm not sending items, but I understand it's required. How can I send just a dummy item that would constitute the order subtotal (i.e. can I just type something into the parameter field int he tag configuration dialog
1 dummyItem $10
Thanks
Mark
Upvotes: 0
Views: 539
Reputation: 32760
If you want a dummy e-commerce item you can create a custom javascript variable that returns a single hard-coded array or object, depending on your tag.
Go to variables, click "new", call it say "dummy product" and select "custom javascript" as variable type.
In the input field, create an anonymous function that returns your data structure. E.g. Universal Analytics expects an array of objects for transaction items, so you could do something like:
function() {
return [
{
"id": "P12345",
"name": "Dummy Products",
"category": "Dummies/Mockups",
"quantity": 1,
"price": "1.0"
}];
}
Now use this in your tag. You can reference the variable in tags by wrapping the variable name in double curls brackets, e.g. {{dummy product}}
.
If you need a plain array instead of an object, you can return that too - the anonymous function works just like any other JS function, and you can just make it return the hardcoded data structure you need.
Upvotes: 1