GTM
by shigetak
HTML
<script>
//$(document).ready(function(){
//ga('create', 'UA-99011699-1', 'auto');
//ga('send', 'pageview');
//}
</script>
JavaScript
(function(window, document, scriptTagString, analyticsURL, gaString, a, m) {
// Remember the name 'ga' on window, using the property GoogleAnalyticsObject
window['GoogleAnalyticsObject'] = gaString;
// Create or retrieve the 'ga' function. If there already is one,
// it's used as-is. If not, create a new function.
window[gaString] = window[gaString] || function() {
// The bit in parens initializes an array if there isn't one
// Then the push call remembers the arguments for this call
(window[gaString].q = window[gaString].q || []).push(arguments)
}, window[gaString].l = 1 * new Date();
// The bit after the comma sets or updates the `l` property on the function with the timestamp of when this code was run.
// From here fairly standard, load the GA script asynchronously
a = document.createElement(scriptTagString), m = document.getElementsByTagName(scriptTagString)[0];
a.async = 1;
a.src = analyticsURL;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-99011699-1', 'auto');
ga(function(tracker) {
var clientId = tracker.get('clientId');
alert(clientId);
var url ='https://service.smt.docomo.ne.jp/procedure2/C0616/ifauth/common/register?serviceCode=C0616&eventCode=001&dcmga_cid=' + clientId;
alert('(1) clientId :' + clientId + '\n\n' + '(2) コチラに飛びます\n' + url);
location.href = url;
});
ga('send', 'pageview');
//ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
ga('send', 'event');
(function (i, s, o, g, r, a, m) {
// Remember the name 'ga' on window, using the property GoogleAnalyticsObject
i['GoogleAnalyticsObject'] = r;
// Create or retrieve the 'ga' function. If there already is one,
// it's used as-is. If not, create a new function.
i[r] = i[r] || function () {
// The bit in parens initializes an array if there isn't one
...