New DataLayer for Product Comparison

Avatar

Avatar
Validate 10
Level 2
vitalin58577727
Level 2

Likes

15 likes

Total Posts

69 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 2
vitalin58577727
Level 2

Likes

15 likes

Total Posts

69 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
vitalin58577727
Level 2

08-03-2019

I have several products in the shop and on a subpage it is possible to compare the products.

Like e.g.

handy-vergleich-seite-amazon.JPG

My question: What does the DataLayer have to look like in order to realize this?

Would such a DataLayer be possible?

digitalData.ProductComparison = {

ComparisonInfo: {

ProductName1: "xxx",

ProductName2: "xxx",

ProductName3: "xxx",

ProductName4: "xxx",

ComparisonDisplayAll:"5-4.5-5.5",

ComparisonBrandAll:"brand1_brand2_brand3",

ComparisonPriceAll:"price1_price2_price3",

}

}

Thx.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Applaud 500
MVP
Asheesh_P
MVP

Likes

130 likes

Total Posts

334 posts

Correct reply

145 solutions
Top badges earned
Applaud 500
Affirm 100
Contributor
Boost 100
Give Back 10
View profile

Avatar
Applaud 500
MVP
Asheesh_P
MVP

Likes

130 likes

Total Posts

334 posts

Correct reply

145 solutions
Top badges earned
Applaud 500
Affirm 100
Contributor
Boost 100
Give Back 10
View profile
Asheesh_P
MVP

11-03-2019

In place for going flat, It would be easy to create an array of product details i.e. somewhat similar to below...

digitalData = {

    comparisonInfo: [{

            productName: "xxx1",

            comparisonDisp: 5,

            comparisonBrand: "brand1",

            comparisonPrice: "price1"

        },

        {

            productName: "xxx2",

            comparisonDisp: 4.5,

            comparisonBrand: "brand2",

            comparisonPrice: "price2"

        },

        {

            productName: "xxx3",

            comparisonDisp: 5.5,

            comparisonBrand: "brand3",

            comparisonPrice: "price3"

        },

        {

            productName: "xxx4",

            comparisonDisp: 4,

            comparisonBrand: "brand4",

            comparisonPrice: "price4"

        }

    ]

}

Then use the forEach loop to iterate through it; change the key name in the code below to get value for different keys. eg. to get value for "comparisonBrand" comparisonBrand"

var foo = []

digitalData.comparisonInfo.forEach(function(e) {

  foo.push(e.comparisonBrand);
  console.log(foo);// remove this line when use in dtm.

});

Good Luck

Answers (2)

Answers (2)

Avatar

Avatar
Applaud 500
MVP
Asheesh_P
MVP

Likes

130 likes

Total Posts

334 posts

Correct reply

145 solutions
Top badges earned
Applaud 500
Affirm 100
Contributor
Boost 100
Give Back 10
View profile

Avatar
Applaud 500
MVP
Asheesh_P
MVP

Likes

130 likes

Total Posts

334 posts

Correct reply

145 solutions
Top badges earned
Applaud 500
Affirm 100
Contributor
Boost 100
Give Back 10
View profile
Asheesh_P
MVP

13-03-2019

Sure! Lmk if you need any help.

Avatar

Avatar
Validate 10
Level 2
vitalin58577727
Level 2

Likes

15 likes

Total Posts

69 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 2
vitalin58577727
Level 2

Likes

15 likes

Total Posts

69 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
vitalin58577727
Level 2

13-03-2019

Hallo asheeshp,

Thanks for the help, I'll put it in this way and see what it becomes.

Thanks