-
-
Save cssimsek/fff267e2e245714ad286 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* piggyback dataLayer data and store in Conversion object */ | |
var Conversion = {}, item, i, conv; | |
if (dataLayer[0].google_tag_params) { | |
for (item in dataLayer[0].google_tag_params) { | |
if(dataLayer[0].google_tag_params.hasOwnProperty(item)){ | |
Conversion[item] = dataLayer[0].google_tag_params[item]; | |
} | |
} | |
} | |
for (i=0;i<dataLayer.length;i+=1) { | |
for (conv in dataLayer[i]) { | |
if(dataLayer[i].hasOwnProperty(conv)){ | |
if (conv === "orderid") { | |
Conversion[conv] = dataLayer[i][conv]; | |
} | |
if (conv === "amount") { | |
Conversion[conv] = dataLayer[i][conv]; | |
} | |
if (conv === "pids") { | |
Conversion[conv] = dataLayer[i][conv]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment