-
Notifications
You must be signed in to change notification settings - Fork 0
/
SubscriberStatDetails.html
155 lines (155 loc) · 5.79 KB
/
SubscriberStatDetails.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
%%[
/*Declare Variables*/
var @SubscriberKey,@Sends,@Opens, @Clicks,@Bounces, @Lists
/*Get Subscriber in content from url*/
Set @SubscriberKey = RequestParameter("SubscriberKey")
]%%
<script runat="server">
Platform.Load("Core","1.1.1");
try{
//Get subscriberKey retrived by AMPscript from URL parameter
var SubscriberKey= Variable.GetValue("@SubscriberKey");
//Set filter for retrieval of tracking data
var filter = {
Property: "SubscriberKey",
SimpleOperator: "equals",
Value: SubscriberKey
};
var sendcols = ["SubscriberKey","EventDate"];
//Initiate WSProxy and set object properties
var sentprox = new Script.Util.WSProxy(),
objectType = "sentEvent",
moreData = true,
reqID = null,
numItems = 0;
//Retrieve data using pagination and set the sent count
while(moreData) {
moreData = false;
var sentdata = reqID == null ?
sentprox.retrieve(objectType, sendcols, filter):
sentprox.getNextBatch(objectType, reqID);
if(sentdata != null) {
moreData = sentdata.HasMoreRows;
reqID = sentdata.RequestID;
if(sentdata && sentdata.Results) {
Write("<div id="+"\"senddata\""+"style="+"\"display:none;\""+"><table border=1 ><tr>");
Write("<th>" + "SubscriberKey" + "</th>");
Write("<th>" + "EventDate" + "</th>");
Write("</tr>");
for(var i=0; i< sentdata.Results.length; i++) {
Write("<tr>");
Write("<td>" + sentdata.Results[i].SubscriberKey + "</td>");
Write("<td>" + sentdata.Results[i].EventDate + "</td>");
}
Write("</tr></table></div>");
}
}
}
var opencols = ["SubscriberKey","EventDate"];
//Initiate WSProxy and set object properties
var openprox = new Script.Util.WSProxy(),
objectType = "openEvent",
moreData = true,
reqID = null,
numItems = 0;
//Retrieve data using pagination and set the open count
var openCount = 0;
while(moreData) {
moreData = false;
var opendata = reqID == null ?
openprox.retrieve(objectType, opencols, filter):
openprox.getNextBatch(objectType, reqID);
if(opendata != null) {
moreData = opendata.HasMoreRows;
reqID = opendata.RequestID;
if(opendata && opendata.Results) {
Write("<div id="+"\"opendata\""+"style="+"\"display:none;\""+"><table border=1 ><tr>");
Write("<th>" + "SubscriberKey" + "</th>");
Write("<th>" + "EventDate" + "</th>");
Write("</tr>");
for(var i=0; i< opendata.Results.length; i++) {
Write("<tr>");
Write("<td>" + opendata.Results[i].SubscriberKey + "</td>");
Write("<td>" + opendata.Results[i].EventDate + "</td>");
}
Write("</tr></table></div>");
}
}
}
//end While more data
var clickcols = ["SubscriberKey","EventDate","URL"];
//Initiate WSProxy and set object properties
var clickprox = new Script.Util.WSProxy(),
objectType = "clickEvent",
moreData = true,
reqID = null,
numItems = 0;
//Retrieve data using pagination and set the open count
var clickCount = 0;
while(moreData) {
moreData = false;
var clickdata = reqID == null ?
clickprox.retrieve(objectType, clickcols, filter):
clickprox.getNextBatch(objectType, reqID);
if(clickdata != null) {
moreData = clickdata.HasMoreRows;
reqID = clickdata.RequestID;
if(clickdata && clickdata.Results) {
Write("<div id="+"\"clickdata\""+"style="+"\"display:none;\""+"><table border=1 ><tr>");
Write("<th>" + "SubscriberKey" + "</th>");
Write("<th>" + "EventDate" + "</th>");
Write("<th>" + "URL" + "</th>");
Write("</tr>");
for(var i=0; i< clickdata.Results.length; i++) {
Write("<tr>");
Write("<td>" + clickdata.Results[i].SubscriberKey + "</td>");
Write("<td>" + clickdata.Results[i].EventDate + "</td>");
Write("<td>" + clickdata.Results[i].URL + "</td>");
}
Write("</tr></table></div>");
}
}
}
//end While more data
var bouncecols = ["SubscriberKey","EventDate","BounceType","BounceCategory"];
//Initiate WSProxy and set object properties
var bounceprox = new Script.Util.WSProxy(),
objectType = "bounceEvent",
moreData = true,
reqID = null,
numItems = 0;
//Retrieve data using pagination and set the open count
var bounceCount = 0;
while(moreData) {
moreData = false;
var bouncedata = reqID == null ?
bounceprox.retrieve(objectType, bouncecols, filter):
bounceprox.getNextBatch(objectType, reqID);
if(bouncedata != null) {
moreData = bouncedata.HasMoreRows;
reqID = bouncedata.RequestID;
if(bouncedata && bouncedata.Results) {
Write("<div id="+"\"bouncedata\""+"style="+"\"display:none;\""+"><table border=1 ><tr>");
Write("<th>" + "SubscriberKey" + "</th>");
Write("<th>" + "EventDate" + "</th>");
Write("<th>" + "BounceType" + "</th>");
Write("<th>" + "BounceCategory" + "</th>");
Write("</tr>");
for(var i=0; i< bouncedata.Results.length; i++) {
Write("<tr>");
Write("<td>" + bouncedata.Results[i].SubscriberKey + "</td>");
Write("<td>" + bouncedata.Results[i].EventDate + "</td>");
Write("<td>" + bouncedata.Results[i].BounceType + "</td>");
Write("<td>" + bouncedata.Results[i].BounceCategory + "</td>");
}
Write("</tr></table></div>");
}
}
}
//end While more data
}
catch(e){
Write(Stringify(e));
}
//End catch
</script>