I hope I am using the correct terms as I am a beginner with JS so please correct me if the terms I am using are incorrect. I am collecting sku
numbers from my website via a dataLayer
and turning it into a variable called DL - Product Detail - SKUs
.When the variable comes across it, it's put into a string. Some products may just come across with a single product sku
string (sku1
) while other pages have multiple product sku
string (sku1
, sku2
, sku3
). What I am trying to do now is this: Create them as single variables, something like this:
- SKUS: sku1
- SKUS: sku2
- SKUS: sku3
I honestly have no idea where to even start. So any suggestions would be appreciated. I have something like this but I don't believe this is the correct direction I need to go.
FYI the {{...}}
are to call the SKUs string from the dataLayer
using Google Tag Manager
.
The _ltk.Activity.AddProductBrowse(productskus);
is where I need to call the SKUs out individually.
(function() {
var productskus = "{{DL - Product Details - SKUs}}";
return productskus('|');
_ltk.Activity.AddProductBrowse(productskus);
_ltk.Activity.Submit();
});
I am not really sure how to give a good minimal example but maybe this will help
This is the object that is pulling through:
object
{
id: '24513',
model: 'Government',
skus: '965000050,965000070,965000146,965000147,965000185,965000244',
}
So I created a variable that calls the skus
out into a string.
var sku = ('965000050,965000070,965000146,965000147,965000185,965000244')
from that sku
variable, I now need each item to be it's own item
for lack of knowing the correct term.