One could argue that analytics purpose is not direct marketing purpose.
My understanding is that as analytics can be considered as a usual/expected business process, it may use legitimate interests as far as it fulfill requirements (information of the process, the right to opt-out, ...).
However, the problem is that analytics may be advanced analytics. Is the retrieval of Adwords parameters from a glcid allowed/expected ? Is the injection of historical behaviour or marketing segment allowed/expected ?
"The processing of personal data for direct marketing purposes may be regarded as carried out for a legitimate interest."
It's also mentioned in Article 21 describing the right to object to processing using legitimate/public interest:
"Where personal data are processed for direct marketing purposes, the data subject shall have the right to object at any time⦠etc."
The ICO has some useful guidance on when it is an appropriate basis: https://ico.org.uk/for-organisations/guide-to-data-protectio...