I'm trying to set Analytics Tracking Event as Download using Sitecore PowerShell script for most media items which have pdf extension.
like this:
Below is the script, I have written but not working
$items = Get-ChildItem -Path "master:/sitecore/media library/Files/Documentation Center/Reports/Reporting Brochure" -Recurse
foreach($item in $items){
$fieldValue = $item."Extension"
if(-Not([string]::IsNullOrEmpty($fieldValue)) -and $item."Extension" -eq "pdf" )
{
$item.Editing.BeginEdit();
$item.Fields["__Tracking"].Value = "<tracking><event id='{FA72E131-3CFD-481C-8E15-04496E9586DC}' name='Download' /></tracking>"
$item.Editing.EndEdit();
}
}