Created
May 24, 2016 07:09
-
-
Save beijaflor/021045ae5aa4a3806efba5e531465b14 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// GTMのdetaLayerから値を走査する | |
// window.dataLayer = [ {"a": "b"}, {"c": "d"} ]; | |
function findDataLayer(key) { | |
if (window.dataLayer == undefined) | |
return false; | |
var dl = window.dataLayer; | |
for (var i = 0; i < dl.length; i++) { | |
if( dl[i][key] !== undefined ) { | |
return dl[i][key]; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment