Hi Ken yes, I had to pull it out of that PDF by screenshotting, using an OCR and then making it sure it was identical. here you go; I have replaced the UA ID for now but my local copy has it ready to go.
EDITED to remove email addys.
/**
- Universal Tracking Code Modified from original code shared by Blastam.com
-
- Original Author:xxx
- Shamelessly Borrowed and Modified by: xxx
-
- Date: 2015-09-30
-
-
** /
preferences {
section(âWhich sensors do you want to track?â) {
input âcontactlâ, âcapability.contactSensorâ, title: âSelect oneâ, multiple: true
}
section(âGoogle lightâŚâ) {
input âswitchlâ, âcapability.switchâ, required: false
}
section(âWhen thereâs movementâŚâ) {
input âmotionlâ, âcapability.motionSensorâ, title: âWhere?â, multiple: false
}
}
def installed() {
subscribe(contactl, âcontactâ, contactHandler)
subscribe(motionl, âmotion.activeâ, motionActiveHandler)
subscribe(motionl, âmotion.inactiveâ, motionInactiveHandler)
initialize()
}
def updated() {
//log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe(contactl, âcontactâ, contactHandler)
subscribe(motionl, âmotion.activeâ, motionActiveHandler)
subscribe(motionl, âmotion.inactiveâ, motionInactiveHandler)
}
def contactHandler(evt) {
if (evt.value == âopenâ) {
httpPost("https://www.google-analytics.com/collect","v=1&tid=UA-xxxxxx&cid=l&t=event&ec=Door - " + evt.displaName + â&ea=Openâ)
switchl.off()
} else if (evt.value == âclosedâ) {
httpPost("https://www.google-analytics.com/collect","v=l&tid=UA-xxxxxx&cid=l&t=event&ec.Door - " + evt.displayName + â&ea=Closeâ)
switchl.on()
}
def motionActiveHandler(evt) {
httpPost("https://www.google-analytics.com/collect","v=l&tid=UA-xxxxxx&cid=l&t=event&ec=Movement - " + evt.displayName + â&ea=Motion_Sensedâ)
}
def motionInactiveHandler(evt) {
httpPost("https://www.google-analytics.com/collect","v=1&tid=UA-xxxxxx&cid=1&t=event&ec=Movement - " + evt.displayName + â&ea=Motion_Ceasedâ)
}