Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LindaLawton/08f3b6b874dfd73eefc06c6244d0005c to your computer and use it in GitHub Desktop.
Save LindaLawton/08f3b6b874dfd73eefc06c6244d0005c to your computer and use it in GitHub Desktop.
sends event to Google Analytics event webhook
/*
* Declaring the variables.
*/
char MyIp[16] ;
char AccountId[20] = "UA-xxxx-1";
char cid[10] = "123";
void setup() {
Serial.begin(9600);
}
void loop() {
char data[1000] ;
sprintf(data,"{ \"v\": \"1\",\"tid\": \"%s\",\"cid\": \"%s\", \"t\": \"event\",\"cd\": \"LivingRoom\",\"an\": \"ParticleTesting\",\"uip\": \"%s\" ,\"cm1\": \"%u\", \"ec\": \"Catagory\", \"ea\": \"Action\",\"ev\": \"%u\"}"
,AccountId
,cid
,WiFi.localIP().toString().c_str()
,1
,1);
Particle.publish("AnalyticsEvent", data, PRIVATE);
delay(10000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment