Last active
September 24, 2025 11:44
-
-
Save Lukas238/c0c14c92edb75e0686b871e853409504 to your computer and use it in GitHub Desktop.
SFMC - Click Activity/Link View download as CSV file button
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
| // ==UserScript== | |
| // @name SFMC - Click Activity/Link View download as CSV file button. | |
| // @namespace https://c238.com.ar | |
| // @version 1.1 | |
| // @description This user scripts add a convenient download as CVS button to SFMC "Click Activity/Link View" under Tracking Reports page in Email Studio. | |
| // @updateURL https://gist.github.com/Lukas238/c0c14c92edb75e0686b871e853409504/raw/SFMC_ClickActivity_Link_View_download_as_csv.user.js | |
| // @downloadURL https://gist.github.com/Lukas238/c0c14c92edb75e0686b871e853409504/raw/SFMC_ClickActivity_Link_View_download_as_csv.user.js | |
| // @author Lucas Dasso - https://github.com/Lukas238 | |
| // @match *.exacttarget.com/*/LinksListing.aspx | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=exacttarget.com | |
| // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| const btn = `<span style="color: #999;border-left: 1px solid #a6a6a6;border-right: 1px solid white;display: inline;margin: 0 5px;"></span><svg width="16" height="16" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: bottom; | |
| margin-right: 4px;"><rect x="8" y="2" width="24" height="28" rx="2" fill="#2FB776"/><path d="M8 23h24v5a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2z" fill="url(#a)"/><path fill="#229C5B" d="M20 16h12v7H20z"/><path fill="#27AE68" d="M20 9h12v7H20z"/><path d="M8 4a2 2 0 0 1 2-2h10v7H8z" fill="#1D854F"/><path fill="#197B43" d="M8 9h12v7H8z"/><path fill="#1B5B38" d="M8 16h12v7H8z"/><path d="M8 12a3 3 0 0 1 3-3h6a3 3 0 0 1 3 3v12a3 3 0 0 1-3 3H8z" fill="#000" fill-opacity=".3"/><rect y="7" width="18" height="18" rx="2" fill="url(#b)"/><path d="m13 21-2.818-5.1 2.694-4.9h-2.199l-1.663 3.129L7.378 11H5.11l2.708 4.9L5 21h2.2l1.773-3.314L10.732 21z" fill="#fff"/><defs><linearGradient id="a" x1="8" y1="26.5" x2="32" y2="26.5" gradientUnits="userSpaceOnUse"><stop stop-color="#163C27"/><stop offset="1" stop-color="#2A6043"/></linearGradient><linearGradient id="b" x1="0" y1="16" x2="18" y2="16" gradientUnits="userSpaceOnUse"><stop stop-color="#185A30"/><stop offset="1" stop-color="#176F3D"/></linearGradient></defs></svg><a href="#" id="c238-export-csv" style="color:inherit !important;">Export to CSV</a>`; | |
| // Add the download button to the correct place in the page layout | |
| $('#notification').html($('#notification').html() + `${btn}`); | |
| $('#toolbar1_3').after(`<td>${btn}</td>`); | |
| const file_name = $('#breadcrumbLabel').text().replace(/[^a-z0-9_]/gi, '_'); // Take the name from the page last breadcrumb | |
| $('#c238-export-csv').on('click', function () { | |
| var data_raw = grid1.Data; | |
| var csv_headers = ['Link,Total,Unique,Net CTRs']; | |
| var csv_data = [...csv_headers, ...data_raw.map(item => `${item[0].replace(/"/g, '\"')},${item[1][0]},${item[2]},${item[3][0]}`)]; | |
| var blob = new Blob([csv_data.join('\n')], { type: 'text/csv;charset=utf-8;' }); | |
| var encodedUri = URL.createObjectURL(blob); | |
| var link = document.createElement('a'); | |
| link.setAttribute('href', encodedUri); | |
| link.setAttribute('download', `${file_name}.csv`); | |
| link.textContent = 'Click to Download'; | |
| link.click(); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment