Skip to content

Commit 1d9996c

Browse files
author
miroslaw.jaroszak
committed
Added optional purchase-complete tracking
1 parent 9b5cffb commit 1d9996c

File tree

5 files changed

+76
-1
lines changed

5 files changed

+76
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

app/code/community/TriggeredMessaging/DigitalDataLayer/Model/Page/Observer.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,25 @@ public function getVersion() {
167167
return $this->_version;
168168
}
169169

170+
public function getPurchaseCompleteQs() {
171+
172+
$orderId = $this->_getCheckoutSession()->getLastOrderId();
173+
if ($orderId) {
174+
$order = $this->_getSalesOrder()->load($orderId);
175+
$email = $order->getCustomerEmail();
176+
}else{
177+
$email = $user->getEmail();
178+
}
179+
$qs = "e=" . urlencode($email);
180+
181+
182+
if($orderId){
183+
$qs = $qs . "&r=" . urlencode($orderId);
184+
}
185+
186+
return $qs;
187+
}
188+
170189
public function getUser() {
171190
return $this->_user;
172191
}

app/design/frontend/base/default/template/triggeredmessaging/digital_data_layer.phtml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
$transaction = $mage->getTransaction();
2121
$events = $mage->getEvents();
2222
?>
23+
24+
25+
26+
27+
28+
2329
<?php
2430
try {
2531
// Extract things only available within template (and not model)
@@ -32,6 +38,8 @@
3238
} catch(Exception $e) {}
3339
?>
3440
<!-- W3C Digital Data Layer Start -->
41+
42+
3543
<script type="text/javascript">
3644
try {
3745
window.digitalData = window.digitalData || {};
@@ -59,10 +67,19 @@ try {
5967
<!-- W3C Digital Data Layer End -->
6068
<?php endif; ?>
6169

70+
6271
<?php if ($triggered_messaging_script_enabled) :?>
72+
6373
<!-- Triggered Messaging Script Start -->
6474
<?php if ($triggered_messaging_website_id) :?>
6575
<script defer="defer" async="async" src='//d81mfvml8p5ml.cloudfront.net/<?php echo $triggered_messaging_website_id; ?>.js'></script>
76+
77+
<?php if ($mage->_isConfirmation()) :?>
78+
<?php $pcqs = $mage->getPurchaseCompleteQs(); ?>
79+
<img src="//d1f0tbk1v3e25u.cloudfront.net/pc/<?php echo $triggered_messaging_website_id; ?>/?<?php echo $pcqs; ?>" />
80+
<?php endif;?>
81+
82+
6683
<?php else: ?>
6784
<script type="text/javascript">
6885
console.log("You have enabled the Triggered Messaging script from the Magento Admin Configuration Panel, but have not supplied a website ID. Please contact hello@triggeredmessaging.com if you would like some assistance.");
@@ -71,4 +88,4 @@ console.log("You have enabled the Triggered Messaging script from the Magento Ad
7188
<!-- Triggered Messaging Script End -->
7289
<?php endif;?>
7390

74-
<?php } catch (Exception $e) {} ?>
91+
<?php } catch (Exception $e) {} ?>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<name>w3c-digital-data-layer-by-triggered-messaging</name>
4+
<version>0.3.1</version>
5+
<stability>stable</stability>
6+
<license uri="http://opensource.org/licenses/apachepl.php">Apache Software License v2</license>
7+
<channel>community</channel>
8+
<extends/>
9+
<summary>Adds the W3C Digital Data Layer spec to your store.</summary>
10+
<description>Adds the W3C Digital Data Layer to Magento. The Digital Data Layer (DDL) is a standardised way of exposing data on your eCommerce site. If you implement to the specification, it will mean that you will not have to duplicate your work to expose data to multiple providers (e.g. an analytics provider and a tag management provider).&#xD;
11+
The plugin also allows easy installation of Triggered Messaging scripts in your store.&#xD;
12+
&#xD;
13+
Any bugs or support requests should be raised here:&#xD;
14+
&#xD;
15+
https://github.com/TriggeredMessaging/digitalDataMagentoExtension/issues</description>
16+
<notes>All basic features included.&#xD;
17+
- It can handle full page caching.&#xD;
18+
- Exception handling has been added.&#xD;
19+
- Removed empty objects and arrays; Removed duplicated subcategories.&#xD;
20+
- Added product data for products on category and search pages.&#xD;
21+
- Fixed issue where configurable products have multiple product entries, and incorrect prices, in the cart object.&#xD;
22+
- Added more data into digitalData object so websites can be debugged.&#xD;
23+
- Configurable products have each of their configurations listed under 'linkedProduct'.&#xD;
24+
- Fixed bug that was breaking some styling.&#xD;
25+
- Added 'pageName' attribute and fixed type of 'returningStatus' object.&#xD;
26+
- Tweaks to configuration panel and default values.&#xD;
27+
- List of all installed non-Magento extensions are exposed (for debug purposes)&#xD;
28+
- Products associated with a Grouped Product have been included.&#xD;
29+
- Minimum prices of grouped and bundled products can be extracted.&#xD;
30+
- Output of debug data can now be controlled through admin configuration panel.&#xD;
31+
- Added optional purchase complete tracking</notes>
32+
<authors><author><name>Muhammed Miah</name><user>momiah1234</user><email>muhammed.miah@triggeredmessaging.com</email></author><author><name>Triggered Messaging</name><user>tmsdemo</user><email>demostore@triggeredmessaging.com</email></author><author><name>Mike Austin</name><user>tmsdemo</user><email>dev@triggeredmessaging.com</email></author></authors>
33+
<date>2014-09-18</date>
34+
<time>12:30:48</time>
35+
<contents><target name="magecommunity"><dir name="TriggeredMessaging"><dir name="DigitalDataLayer"><dir name="Block"><file name="Ddl.php" hash="134766e2a49c3ecfbf03d1025dd41e8b"/></dir><dir name="Helper"><file name="Data.php" hash="5a6e19225e7db056946c95b1477e5c18"/></dir><dir name="Model"><dir name="Container"><file name="Ddl.php" hash="cc9dcd8cf4e460a01c242ac675ce5634"/></dir><file name="Observer.php" hash="26e0dcfc7a19d5310e44e004c144c23e"/><dir name="Page"><file name="Observer.php" hash="15944e28c9d5e7d886cecb033990e5d1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8b98dee82241e0b69661bf4699cba334"/><file name="cache.xml" hash="1b6658073a8126cd655cb18109559f49"/><file name="config.xml" hash="a29f9fb1250c40a8d973e470ffab46ac"/><file name="system.xml" hash="a72e032172f1a6b05ba969415bf33f63"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="triggeredmessaging"><file name="digital_data_layer.phtml" hash="f6c3639b065e167b72692e3f7dc29962"/><file name="digital_data_layer_after_content.phtml" hash="6ee383b4d2011fd7e718b2930b7cd95d"/></dir></dir><dir name="layout"><dir name="triggeredmessaging"><file name="digital_data_layer.xml" hash="3c58b9faec1d9c63e1fb0a3fcc35a2d8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="TriggeredMessaging_DigitalDataLayer.xml" hash="cfc3b1bff54f3e1f224f120e536bc411"/></dir></target></contents>
36+
<compatible/>
37+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
38+
</package>
12.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)