nrsutton / visitor-tracker
追踪访客在您网站上的路径
dev-master
2016-04-18 10:57 UTC
Requires
- silverstripe/cms: ~3.1
- silverstripe/framework: ~3.1
This package is not auto-updated.
Last update: 2024-09-28 18:00:01 UTC
README
访客追踪器允许您将访客在您网站上的路径附加到任何联系表单提交。
要使用它,通过将文件放置在您选择的SilverStripe项目根目录中的目录中来安装访客追踪器。
然后在提交表单数据的方法中,添加以下代码
$email = new Email(
'email_from',
'email_to',
'email_subject'
);
$email->setTemplate( 'YourEmailTemplate' );
$data = $this->getData();
$data[ "Visitor" ] = Visitor::initVisitor();
$email->populateTemplate( $data );
这使您能够访问访客对象的字段,从而访问页面视图对象的数组
以下是一个电子邮件模板的演示
<html>
<body>
<p><font face="arial" size="2">An enquiry has been received with the following details:</font></p>
<ul>
<li><font face="arial" size="2"><strong>Name:</strong> $Name</font></li>
<li><font face="arial" size="2"><strong>Contact Information:</strong> $ContactInfo</font></li>
<li><font face="arial" size="2"><strong>Enquiry:</strong> $Enquiry</font></li>
</ul>
<% if $Visitor %>
<br/><hr width="75%">
<h2 margin="0"><font face="arial" size="3">Site usage details</font></h2>
<p><font face="arial" size="2">
Below are the details of this users path through the site
</font></p>
<% if $Visitor.referer %>
<p><font face="arial" size="2"><strong>Referal URL:</strong> $Visitor.referer</p>
<% end_if %>
<table border=1>
<tr>
<th>
<font face="arial" size="2">URL</font>
</th>
<th>
<font face="arial" size="2">Scroll depth</font>
</th>
<th>
<font face="arial" size="2">Time on page (Seconds)</font>
</th>
</tr>
<% loop $Visitor.PageViews %>
<tr>
<td>
<font face="arial" size="2">$URL</font>
</td>
<td>
<font face="arial" size="2">
<% if Last %>
No data
<% else %>
$ScrollDepth%
<% end_if %>
</font>
</td>
<td>
<font face="arial" size="2">
<% if Last %>
No data
<% else %>
$TimeOnPage
<% end_if %>
</font>
</td>
</tr>
<% end_loop %>
</table>
<% end_if %>
</body>
</html>
请注意,列表中最后访问的页面将没有滚动深度或页面时间。