Я новичок в JS, и у меня проблемы с приведенным ниже кодом.
Проблема в том, что reffMedium
возвращает ""
:
var reffCookie = 'adwords';
var reffCookieArray = reffCookie.split('|');
var reffLastNdSource = reffCookieArray[reffCookieArray.length - 1];
var reffSource;
var reffMedium;
var reffCampaign;
if (reffLastNdSource.includes("direct")) {
reffSource = 'direct';
reffMedium = 'none.';
reffCampaign = '';
} else if (reffLastNdSource.includes("adwords")) {
reffSource = 'google';
reffMedium = 'cpc';
reffCampaign = '';
} else if (reffLastNdSource.includes("www.google.com")) {
reffSource = 'google';
reffMedium = 'organic';
reffCampaign = '';
} else if (reffLastNdSource.includes("campaign"))
reffSource = reffLastNdSource.substring(
reffLastNdSource.lastIndexOf("s:[") + 1,
reffLastNdSource.lastIndexOf("]")
);
reffMedium = reffLastNdSource.substring(
reffLastNdSource.lastIndexOf("m:[") + 1,
reffLastNdSource.lastIndexOf("]s:[")
);
reffCampaign = reffLastNdSource.substring(
reffLastNdSource.lastIndexOf("c:[") + 1,
reffLastNdSource.lastIndexOf("]m:[")
);
document.getElementById('reff_source').value = reffSource;
document.getElementById('reff_medium').value = reffMedium;
document.getElementById('reff_medium').value = reffCampaign;
Спасибо, что помогли мне.